X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fresthooks%2Fresthooks.go;h=9ac49f921b79bc8f9fc4c98cfeb46a040d423247;hb=d3aa5b98789c65107e5ac41fc5be11f08acf11d8;hp=dd3a578fafe069665443553cab069e00aa2d0219;hpb=f8b9966cb19eeeffc0100b8bb3a0b66937e51aba;p=ric-plt%2Fappmgr.git diff --git a/pkg/resthooks/resthooks.go b/pkg/resthooks/resthooks.go index dd3a578..9ac49f9 100755 --- a/pkg/resthooks/resthooks.go +++ b/pkg/resthooks/resthooks.go @@ -33,9 +33,13 @@ import ( ) func NewResthook(restoreData bool) *Resthook { + return createResthook(restoreData, sdl.NewSdlInstance("appmgr", sdl.NewDatabase())) +} + +func createResthook(restoreData bool, sdlInst iSdl) *Resthook { rh := &Resthook{ client: &http.Client{}, - db: sdl.NewSdlInstance("appmgr", sdl.NewDatabase()), + db: sdlInst, } if restoreData { @@ -51,7 +55,8 @@ func (rh *Resthook) AddSubscription(sr models.SubscriptionRequest) *models.Subsc r := v.Val.(SubscriptionInfo).req if *r.Data.TargetURL == *sr.Data.TargetURL && r.Data.EventType == sr.Data.EventType { appmgr.Logger.Info("Similar subscription already exists!") - return &models.SubscriptionResponse{} + resp := v.Val.(SubscriptionInfo).resp + return &resp } } @@ -175,7 +180,6 @@ func (rh *Resthook) retry(s SubscriptionInfo, fn func() error) error { func (rh *Resthook) StoreSubscriptions(m cmap.ConcurrentMap) { for v := range m.Iter() { s := v.Val.(SubscriptionInfo) - data, err := json.Marshal(s.req) if err != nil { appmgr.Logger.Error("json.marshal failed: %v ", err.Error())