Initial version
[ric-plt/xapp-frame.git] / README.md
1 # XAPP-FRAME
2
3 ## Introduction
4 **xapp-frame** is a simple framework for rapid development of RIC xapps, and supports various services essential for RIC xapps such as RESTful APIs, RMR (RIC Message Routing), database backend services and watching and populating config-map changes in K8S environment.
5
6 ## Architecture
7
8 ![Architecture](assets/xappframe-arch.png)
9
10 ## Features and Components
11
12 * RESTful support
13 * Health check/probes (readiness and liveliness)
14 * Reading and watching config-map
15 * RMR messaging
16 * SDL
17 * Loggind and tracing
18 * Encoding and decoding of commonly used RIC ASN.1 messages
19 * And more to come
20
21 ## Quick Start
22
23 #### Below is a simple example xapp. For more information, see the sample code in the xapp/examples folder:
24 ```go
25 package main
26
27 import "gitlabe1.ext.net.nokia.com/ric_dev/nokia-xapps/xapp/pkg/xapp"
28
29 type MessageCounsumer struct {
30 }
31
32 func (m MessageCounsumer) Consume(mtype, len int, payload []byte) (err error) {
33         xapp.Logger.Debug("Message received - type=%d len=%d", mtype, len)
34
35         xapp.Sdl.Store("myKey", payload)
36         xapp.Rmr.Send(10005, len, payload)
37         return nil
38 }
39
40 func main() {
41     xapp.Run(MessageCounsumer{})
42 }
43 ```
44 #### Installing and running the example xapp
45
46     git clone git@gitlabe1.ext.net.nokia.com:ric_dev/nokia-xapps/xapp.git
47
48 #### Build and run
49     unset GOPATH
50     cd xapp/examples
51     go build example-xapp.go
52     ./example-xapp
53
54 Congratulations! You've just built your first **xapp** application.
55
56 ## API
57 #### API List
58  * TBD
59
60 #### API Usage and Examples
61 * Setting logging level and writing to log
62     ```
63     xapp.Logger.SetLevel(4)
64     xapp.Logger.Info("Status inquiry ...")
65     ```
66 * Storing key-value data to SDL
67     ```
68     xapp.Sdl.Store("myKey", payload)
69     ```
70 * Sending RMR messages
71     ```
72     mid := Rmr.GetRicMessageId("RIC_SUB_RESP")
73     xapp.Rmr.Send(mid, 1234, len, payload)
74     ```
75 * Injecting REST API resources (URL)
76     ```
77     xapp.Resource.InjectRoute("/ric/v1/health/stat", statisticsHandler, "GET")
78     Resource.InjectQueryRoute("/ric/v1/user", handler, "GET", "foo", "bar", "id", "mykey")
79     ```
80
81 ## Documentation
82
83 ## Community
84
85 ## License
86 This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details