Initial version
[ric-plt/xapp-frame.git] / test / xapp / forwarder.go
1 package main
2
3 import (
4         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
5 )
6
7 type Forwarder struct {
8 }
9
10 func (m Forwarder) Consume(mtype, subId, len int, payload []byte) (err error) {
11         xapp.Logger.Debug("Message received - type=%d subId=%d len=%d", mtype, subId, len)
12
13         // Store data and reply with the same message payload
14         if xapp.Config.GetInt("test.store") != 0 {
15                 xapp.Sdl.Store("myKey", payload)
16         }
17
18         mid := xapp.Config.GetInt("test.mtype")
19         if mid != 0 {
20                 mtype = mid
21         } else {
22                 mtype = mtype + 1
23         }
24
25         sid := xapp.Config.GetInt("test.subId")
26         if sid != 0 {
27                 subId = sid
28         }
29
30         if ok := xapp.Rmr.Send(mtype, subId, len, payload); !ok {
31                 xapp.Logger.Info("Rmr.Send failed ...")
32         }
33         return
34 }
35
36 func forwarder() {
37         xapp.Run(Forwarder{})
38 }