import (
"bytes"
"encoding/json"
- sdl "gerrit.oran-osc.org/r/ric-plt/sdlgo"
+ sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
cmap "github.com/orcaman/concurrent-map"
"github.com/segmentio/ksuid"
"net/http"
"time"
- "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/appmgr"
- "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/appmgr"
+ "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/models"
)
-func NewResthook() *Resthook {
+func NewResthook(restoreData bool) *Resthook {
rh := &Resthook{
client: &http.Client{},
db: sdl.NewSdlInstance("appmgr", sdl.NewDatabase()),
}
- rh.subscriptions = rh.RestoreSubscriptions()
+ if restoreData {
+ rh.subscriptions = rh.RestoreSubscriptions()
+ } else {
+ rh.subscriptions = cmap.New()
+ }
return rh
}
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
}
}
}
func (rh *Resthook) notify(xapps models.AllDeployedXapps, et models.EventType, s SubscriptionInfo, seq int64) error {
- notif := models.SubscriptionNotification{ID: s.Id, Version: seq, EventType: et, XApps: xapps}
+ xappData, err := json.Marshal(xapps)
+ if err != nil {
+ appmgr.Logger.Info("json.Marshal failed: %v", err)
+ return err
+ }
+
+ // TODO: Use models.SubscriptionNotification instead of internal ...
+ notif := SubscriptionNotification{ID: s.Id, Version: seq, Event: string(et), XApps: string(xappData)}
jsonData, err := json.Marshal(notif)
if err != nil {
appmgr.Logger.Info("json.Marshal failed: %v", err)