Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 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 | |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 10 | func (m Forwarder) Consume(params *xapp.RMRParams) (err error) { |
| 11 | xapp.Logger.Debug("Message received - type=%d subId=%d meid=%v xid=%v", params.Mtype, params.SubId, params.Meid, params.Xid) |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 12 | |
| 13 | // Store data and reply with the same message payload |
| 14 | if xapp.Config.GetInt("test.store") != 0 { |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 15 | xapp.Sdl.Store("myKey", params.Payload) |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | mid := xapp.Config.GetInt("test.mtype") |
| 19 | if mid != 0 { |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 20 | params.Mtype = mid |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 21 | } else { |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 22 | params.Mtype = params.Mtype + 1 |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | sid := xapp.Config.GetInt("test.subId") |
| 26 | if sid != 0 { |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 27 | params.SubId = sid |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 28 | } |
| 29 | |
Mohamed Abukar | f11ab7a | 2019-08-14 16:55:01 +0300 | [diff] [blame^] | 30 | if ok := xapp.Rmr.SendMsg(params); !ok { |
Mohamed Abukar | 2e78e42 | 2019-06-02 11:45:52 +0300 | [diff] [blame] | 31 | xapp.Logger.Info("Rmr.Send failed ...") |
| 32 | } |
| 33 | return |
| 34 | } |
| 35 | |
| 36 | func forwarder() { |
| 37 | xapp.Run(Forwarder{}) |
| 38 | } |