From: naman.gupta Date: Wed, 7 Dec 2022 10:48:18 +0000 (+0530) Subject: Moving RMR message reciver into go routine X-Git-Tag: 3.0.0~9 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=9f4fe4d725c9ad77ea1c2ab565ce5759e8a932a6;p=ric-plt%2Fa1.git Moving RMR message reciver into go routine Moving RMR message reciver into go routine and some typo error Signed-off-by: naman.gupta Change-Id: I2841b57a9932813366de26318d48d07df7776b3d --- diff --git a/a1-go/pkg/resthooks/resthooks.go b/a1-go/pkg/resthooks/resthooks.go index cb87040..dcffe2a 100644 --- a/a1-go/pkg/resthooks/resthooks.go +++ b/a1-go/pkg/resthooks/resthooks.go @@ -530,6 +530,7 @@ func (rh *Resthook) typeValidity(policyTypeId models.PolicyTypeID) error { a1.Logger.Error("policy type Not Present for policyid : %v", policyTypeId) return policyTypeNotFoundError } + return nil } func (rh *Resthook) instanceValidity(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) error { @@ -546,6 +547,7 @@ func (rh *Resthook) instanceValidity(policyTypeId models.PolicyTypeID, policyIns a1.Logger.Debug("policy instance Not Present ") return policyInstanceNotFoundError } + return nil } func (rh *Resthook) getMetaData(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) (map[string]interface{}, error) { @@ -567,11 +569,11 @@ func (rh *Resthook) getMetaData(policyTypeId models.PolicyTypeID, policyInstance func (rh *Resthook) GetPolicyInstanceStatus(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) (*a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody, error) { err := rh.instanceValidity(policyTypeId, policyInstanceID) + policyInstanceStatus := a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody{} if err != nil && err == policyInstanceNotFoundError || err == policyTypeNotFoundError { policyInstanceStatus.InstanceStatus = "NOT IN EFFECT" return &policyInstanceStatus, err } - policyInstanceStatus := a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody{} metadata, err := rh.getMetaData(policyTypeId, policyInstanceID) a1.Logger.Debug(" metadata %v", metadata) if err != nil { diff --git a/a1-go/pkg/resthooks/resthooks_test.go b/a1-go/pkg/resthooks/resthooks_test.go index a9fcc1e..ac3dc25 100644 --- a/a1-go/pkg/resthooks/resthooks_test.go +++ b/a1-go/pkg/resthooks/resthooks_test.go @@ -230,8 +230,9 @@ func TestGetPolicyInstanceStatus(t *testing.T) { keys[0] = instancekey sdlInst.On("Get", a1MediatorNs, keys[:]).Return(httpBody) - resp := rh.GetPolicyInstanceStatus(policyTypeId, policyInstanceID) + resp, errresp := rh.GetPolicyInstanceStatus(policyTypeId, policyInstanceID) + assert.Nil(t, errresp) assert.NotNil(t, resp) sdlInst.AssertExpectations(t) } diff --git a/a1-go/pkg/rmr/rmr.go b/a1-go/pkg/rmr/rmr.go index b7cac0e..c0366af 100644 --- a/a1-go/pkg/rmr/rmr.go +++ b/a1-go/pkg/rmr/rmr.go @@ -264,6 +264,6 @@ func (rmr *RmrSender) Consume(msg *xapp.RMRParams) (err error) { func (rmr *RmrSender) RmrRecieveStart() { a1.Logger.Debug("Inside RmrRecieveStart function ") - rmr.rmrclient.Start(rmr) + go rmr.rmrclient.Start(rmr) a1.Logger.Debug("Reciever started") }