Add models
[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 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
28
29 type ExampleXapp struct {
30 }
31
32 func (m *ExampleXapp) Consume(rp *xapp.RMRParams) (err error) {
33         xapp.Logger.Debug("Message received - type=%d len=%d", rp.Mtype, rp.PayloadLen)
34
35         xapp.Sdl.Store("myKey", rp.Payload)
36         xapp.Rmr.Send(r)
37         return nil
38 }
39
40 func main() {
41        xapp.Run(ExampleXapp{})
42 }
43 ```
44 #### Building and running the example xapp
45
46     git clone https://gerrit.o-ran-sc.org/r/ric-plt/xapp-frame
47     cd xapp-frame
48
49 #### To generate an executable binary for our sample xApp application, run the following command:
50
51     GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o example-xapp examples/example-xapp.go
52
53 #### To run the generated executable binary locally, run the following command:
54
55     RMR_SEED_RT=config/uta_rtg.rt ./example-xapp -f config/config-file.yaml
56
57 Congratulations! You've just built your first **xapp** application.
58
59 ## API
60 #### API List
61  * TBD
62
63 #### API Usage and Examples
64 * Setting logging level and writing to log
65     ```
66     xapp.Logger.SetLevel(4)
67     xapp.Logger.Info("Status inquiry ...")
68     ```
69 * Storing key-value data to SDL
70     ```
71     xapp.Sdl.Store("myKey", payload)
72     ```
73 * Sending RMR messages
74     ```
75     mid := Rmr.GetRicMessageId("RIC_SUB_RESP")
76     xapp.Rmr.Send(mid, 1234, len, payload)
77     ```
78 * Injecting REST API resources (URL)
79     ```
80     xapp.Resource.InjectRoute("/ric/v1/health/stat", statisticsHandler, "GET")
81     Resource.InjectQueryRoute("/ric/v1/user", handler, "GET", "foo", "bar", "id", "mykey")
82     ```
83
84 ## Documentation
85
86 ## Community
87
88 ## License
89 This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details
90