Xapp-frame, v0.8.1 Rest Subscription Creation /Query /Deletion
[ric-plt/submgr.git] / pkg / control / transaction.go
index df4d7db..efb630c 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"
 )
 
 //-----------------------------------------------------------------------------
@@ -46,14 +47,17 @@ type Transaction struct {
        Seq       uint64           //transaction sequence
        tracker   *Tracker         //tracker instance
        Meid      *xapp.RMRMeid    //meid transaction related
-       ReqId     RequestId        //
        Mtype     int              //Encoded message type to be send
        Payload   *e2ap.PackedData //Encoded message to be send
        EventChan chan interface{}
 }
 
 func (t *Transaction) String() string {
-       return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + "/" + t.ReqId.String() + ")"
+       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) {
@@ -83,12 +87,6 @@ func (t *Transaction) WaitEvent(waittime time.Duration) (interface{}, bool) {
        return event, false
 }
 
-func (t *Transaction) GetReqId() *RequestId {
-       t.mutex.Lock()
-       defer t.mutex.Unlock()
-       return &t.ReqId
-}
-
 func (t *Transaction) GetMtype() int {
        t.mutex.Lock()
        defer t.mutex.Unlock()
@@ -104,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
 }
-
+*/
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -132,7 +131,7 @@ func (t *TransactionSubs) Release() {
 //
 //-----------------------------------------------------------------------------
 type TransactionXappKey struct {
-       RmrEndpoint
+       xapp.RmrEndpoint
        Xid string // xapp xid in req
 }
 
@@ -144,8 +143,9 @@ func (key *TransactionXappKey) String() string {
 //
 //-----------------------------------------------------------------------------
 type TransactionXapp struct {
-       Transaction                     //
-       XappKey     *TransactionXappKey //
+       Transaction
+       XappKey   *TransactionXappKey
+       RequestId e2ap.RequestId
 }
 
 func (t *TransactionXapp) String() string {
@@ -153,10 +153,10 @@ func (t *TransactionXapp) String() string {
        if t.XappKey != nil {
                transkey = t.XappKey.String()
        }
-       return "transxapp(" + t.Transaction.String() + "/" + transkey + ")"
+       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 {
@@ -174,6 +174,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()
@@ -182,6 +183,12 @@ func (t *TransactionXapp) GetSrc() string {
        }
        return ""
 }
+*/
+func (t *TransactionXapp) GetSubId() uint32 {
+       t.mutex.Lock()
+       defer t.mutex.Unlock()
+       return t.RequestId.InstanceId
+}
 
 func (t *TransactionXapp) Release() {
        t.mutex.Lock()