RIC:1060: Change in PTL
[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(params *xapp.RMRParams) (err error) {
11         xapp.Logger.Debug("Message received - type=%d txid=%s subId=%d meid=%s",
12                 params.Mtype, params.Xid, params.SubId, params.Meid.RanName)
13
14         // Store data and reply with the same message payload
15         if xapp.Config.GetInt("test.store") != 0 {
16                 xapp.Sdl.Store("myKey", params.Payload)
17         }
18
19         mid := xapp.Config.GetInt("test.mtype")
20         if mid != 0 {
21                 params.Mtype = mid
22         } else {
23                 params.Mtype = params.Mtype + 1
24         }
25
26         sid := xapp.Config.GetInt("test.subId")
27         if sid != 0 {
28                 params.SubId = sid
29         }
30
31         if ok := xapp.Rmr.SendRts(params); !ok {
32                 xapp.Logger.Info("Rmr.Send failed ...")
33         }
34         return
35 }
36
37 func forwarder() {
38         xapp.Run(Forwarder{})
39 }