xapp-frame v0.8.2 integration to submgr
[ric-plt/submgr.git] / pkg / control / transaction.go
index 56dff1d..f3d5c17 100644 (file)
 package control
 
 import (
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-       "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "strconv"
        "sync"
        "time"
+
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+       "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 )
 
 //-----------------------------------------------------------------------------
@@ -52,7 +53,11 @@ type Transaction struct {
 }
 
 func (t *Transaction) String() string {
-       return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + ")"
+       meidstr := "N/A"
+       if t.Meid != nil {
+               meidstr = t.Meid.String()
+       }
+       return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + meidstr + ")"
 }
 
 func (t *Transaction) SendEvent(event interface{}, waittime time.Duration) (bool, bool) {
@@ -97,12 +102,13 @@ func (t *Transaction) GetMeid() *xapp.RMRMeid {
        return nil
 }
 
+/*  // This function is not used. Commented out to get better test coverage result
 func (t *Transaction) GetPayload() *e2ap.PackedData {
        t.mutex.Lock()
        defer t.mutex.Unlock()
        return t.Payload
 }
-
+*/
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -125,7 +131,8 @@ func (t *TransactionSubs) Release() {
 //
 //-----------------------------------------------------------------------------
 type TransactionXappKey struct {
-       RmrEndpoint
+       InstanceID uint32
+       xapp.RmrEndpoint
        Xid string // xapp xid in req
 }
 
@@ -138,8 +145,8 @@ func (key *TransactionXappKey) String() string {
 //-----------------------------------------------------------------------------
 type TransactionXapp struct {
        Transaction
-       XappKey *TransactionXappKey
-       SubId   uint32
+       XappKey   *TransactionXappKey
+       RequestId e2ap.RequestId
 }
 
 func (t *TransactionXapp) String() string {
@@ -147,10 +154,10 @@ func (t *TransactionXapp) String() string {
        if t.XappKey != nil {
                transkey = t.XappKey.String()
        }
-       return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.SubId), 10) + ")"
+       return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.RequestId.InstanceId), 10) + ")"
 }
 
-func (t *TransactionXapp) GetEndpoint() *RmrEndpoint {
+func (t *TransactionXapp) GetEndpoint() *xapp.RmrEndpoint {
        t.mutex.Lock()
        defer t.mutex.Unlock()
        if t.XappKey != nil {
@@ -168,6 +175,7 @@ func (t *TransactionXapp) GetXid() string {
        return ""
 }
 
+/*  // This function is not used. Commented out to get better test coverage result
 func (t *TransactionXapp) GetSrc() string {
        t.mutex.Lock()
        defer t.mutex.Unlock()
@@ -176,11 +184,11 @@ func (t *TransactionXapp) GetSrc() string {
        }
        return ""
 }
-
+*/
 func (t *TransactionXapp) GetSubId() uint32 {
        t.mutex.Lock()
        defer t.mutex.Unlock()
-       return t.SubId
+       return t.RequestId.InstanceId
 }
 
 func (t *TransactionXapp) Release() {