X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fclient.go;h=41464281ce2e56e11b7c034921725f424141c53f;hb=refs%2Fchanges%2F06%2F2306%2F1;hp=adc03d15ea77ffbb27885f136eebcc6fe05d7b33;hpb=422d018f94aedd9f4c001176b5ff06c786de28eb;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/client.go b/pkg/control/client.go index adc03d1..4146428 100644 --- a/pkg/control/client.go +++ b/pkg/control/client.go @@ -27,6 +27,7 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" "strconv" "strings" + "time" ) //----------------------------------------------------------------------------- @@ -46,21 +47,34 @@ func (sri *SubRouteInfo) String() string { // //----------------------------------------------------------------------------- type RtmgrClient struct { - rtClient *rtmgrclient.RoutingManager - xappHandleParams *rtmgrhandle.ProvideXappSubscriptionHandleParams - xappDeleteParams *rtmgrhandle.DeleteXappSubscriptionHandleParams + rtClient *rtmgrclient.RoutingManager } func (rc *RtmgrClient) SubscriptionRequestUpdate(subRouteAction SubRouteInfo) error { subID := int32(subRouteAction.SubID) xapp.Logger.Debug("%s ongoing", subRouteAction.String()) - xappSubReq := rtmgr_models.XappSubscriptionData{&subRouteAction.EpList.Endpoints[0].Addr, &subRouteAction.EpList.Endpoints[0].Port, &subID} var err error switch subRouteAction.Command { case CREATE: - _, err = rc.rtClient.Handle.ProvideXappSubscriptionHandle(rc.xappHandleParams.WithXappSubscriptionData(&xappSubReq)) + createData := rtmgr_models.XappSubscriptionData{&subRouteAction.EpList.Endpoints[0].Addr, &subRouteAction.EpList.Endpoints[0].Port, &subID} + createHandle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second) + createHandle.WithXappSubscriptionData(&createData) + _, err = rc.rtClient.Handle.ProvideXappSubscriptionHandle(createHandle) case DELETE: - _, _, err = rc.rtClient.Handle.DeleteXappSubscriptionHandle(rc.xappDeleteParams.WithXappSubscriptionData(&xappSubReq)) + deleteData := rtmgr_models.XappSubscriptionData{&subRouteAction.EpList.Endpoints[0].Addr, &subRouteAction.EpList.Endpoints[0].Port, &subID} + deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second) + deleteHandle.WithXappSubscriptionData(&deleteData) + _, _, err = rc.rtClient.Handle.DeleteXappSubscriptionHandle(deleteHandle) + case UPDATE: + updateData := rtmgr_models.XappList{} + for i := range subRouteAction.EpList.Endpoints { + updateData[i] = &rtmgr_models.XappElement{Address: &subRouteAction.EpList.Endpoints[i].Addr, Port: &subRouteAction.EpList.Endpoints[i].Port} + } + updateHandle := rtmgrhandle.NewUpdateXappSubscriptionHandleParamsWithTimeout(10 * time.Second) + updateHandle.WithSubscriptionID(subRouteAction.SubID) + updateHandle.WithXappList(updateData) + _, err = rc.rtClient.Handle.UpdateXappSubscriptionHandle(updateHandle) + default: return fmt.Errorf("%s unknown", subRouteAction.String()) }