Subscription REST interface update
[ric-plt/submgr.git] / pkg / control / subscription.go
index 5243093..1152520 100644 (file)
@@ -21,9 +21,8 @@ package control
 
 import (
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-       "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-       //"reflect"
+
        "sync"
 )
 
@@ -31,20 +30,31 @@ import (
 //
 //-----------------------------------------------------------------------------
 type Subscription struct {
-       mutex     sync.Mutex                    // Lock
-       valid     bool                          // valid
-       registry  *Registry                     // Registry
-       ReqId     RequestId                     // ReqId (Requestor Id + Seq Nro a.k.a subsid)
-       Meid      *xapp.RMRMeid                 // Meid/ RanName
-       EpList    xapptweaks.RmrEndpointList    // Endpoints
-       TransLock sync.Mutex                    // Lock transactions, only one executed per time for subs
-       TheTrans  TransactionIf                 // Ongoing transaction
-       SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information
-       SubRFMsg  interface{}                   // Subscription information
+       mutex            sync.Mutex                    // Lock
+       valid            bool                          // valid
+       registry         *Registry                     // Registry
+       ReqId            RequestId                     // ReqId (Requestor Id + Seq Nro a.k.a subsid)
+       Meid             *xapp.RMRMeid                 // Meid/RanName
+       EpList           xapp.RmrEndpointList          // Endpoints
+       RMRRouteCreated  bool                          // Does subscription have RMR route
+       TransLock        sync.Mutex                    // Lock transactions, only one executed per time for subs
+       TheTrans         TransactionIf                 // Ongoing transaction
+       SubReqMsg        *e2ap.E2APSubscriptionRequest // Subscription information
+       SubRFMsg         interface{}                   // Subscription information
+       PolicyUpdate     bool                          // This is true when policy subscrition is being updated. Used not to send delete for update after timeout or restart
+       RetryFromXapp    bool                          // Retry form xApp for subscription that already exist
+       SubRespRcvd      bool                          // Subscription response received
+       DeleteFromDb     bool                          // Delete subscription from db
+       NoRespToXapp     bool                          // Send no response for subscription delete to xApp after restart
+       DoNotWaitSubResp bool                          // Test flag. Response is not waited for Subscription Request
 }
 
 func (s *Subscription) String() string {
-       return "subs(" + s.ReqId.String() + "/" + (&xapptweaks.RMRMeid{s.Meid}).String() + "/" + s.EpList.String() + ")"
+       meidstr := "N/A"
+       if s.Meid != nil {
+               meidstr = s.Meid.String()
+       }
+       return "subs(" + s.ReqId.String() + "/" + meidstr + "/" + s.EpList.String() + ")"
 }
 
 func (s *Subscription) GetCachedResponse() (interface{}, bool) {
@@ -70,10 +80,7 @@ func (s *Subscription) GetReqId() *RequestId {
 func (s *Subscription) GetMeid() *xapp.RMRMeid {
        s.mutex.Lock()
        defer s.mutex.Unlock()
-       if s.Meid != nil {
-               return s.Meid
-       }
-       return nil
+       return s.Meid
 }
 
 func (s *Subscription) GetTransaction() TransactionIf {
@@ -154,8 +161,6 @@ func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APS
                                        return false
                                }
                        }
-                       //reflect.DeepEqual(acts.ActionDefinitionChoice, actt.ActionDefinitionChoice)
-
                        if acts.SubsequentAction.Present != actt.SubsequentAction.Present ||
                                acts.SubsequentAction.Type != actt.SubsequentAction.Type ||
                                acts.SubsequentAction.TimetoWait != actt.SubsequentAction.TimetoWait {
@@ -163,6 +168,5 @@ func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APS
                        }
                }
        }
-
        return true
 }