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.
8 ![Architecture](assets/xappframe-arch.png)
10 ## Features and Components
13 * Health check/probes (readiness and liveliness)
14 * Reading and watching config-map
18 * Encoding and decoding of commonly used RIC ASN.1 messages
23 #### Below is a simple example xapp. For more information, see the sample code in the xapp/examples folder:
27 import "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
29 type ExampleXapp struct {
32 func (m *ExampleXapp) Consume(rp *xapp.RMRParams) (err error) {
33 xapp.Logger.Debug("Message received - type=%d len=%d", rp.Mtype, rp.PayloadLen)
35 xapp.Sdl.Store("myKey", rp.Payload)
41 xapp.Run(ExampleXapp{})
44 #### Building and running the example xapp
46 git clone https://gerrit.o-ran-sc.org/r/ric-plt/xapp-frame
49 #### To generate an executable binary for our sample xApp application, run the following command:
51 GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o example-xapp examples/example-xapp.go
53 #### To run the generated executable binary locally, run the following command:
55 RMR_SEED_RT=config/uta_rtg.rt ./example-xapp -f config/config-file.yaml
57 Congratulations! You've just built your first **xapp** application.
63 #### API Usage and Examples
64 * Setting logging level and writing to log
66 xapp.Logger.SetLevel(4)
67 xapp.Logger.Info("Status inquiry ...")
69 * Storing key-value data to SDL
71 xapp.Sdl.Store("myKey", payload)
73 * Sending RMR messages
75 mid := Rmr.GetRicMessageId("RIC_SUB_RESP")
76 xapp.Rmr.Send(mid, 1234, len, payload)
78 * Injecting REST API resources (URL)
80 xapp.Resource.InjectRoute("/ric/v1/health/stat", statisticsHandler, "GET")
81 Resource.InjectQueryRoute("/ric/v1/user", handler, "GET", "foo", "bar", "id", "mykey")
89 This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details