Code Review
/
ric-plt
/
appmgr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Return service names of xApps instead of IP
[ric-plt/appmgr.git]
/
cmd
/
appmgr
/
subscriptions.go
diff --git
a/cmd/appmgr/subscriptions.go
b/cmd/appmgr/subscriptions.go
index
40735a9
..
53bc212
100755
(executable)
--- a/
cmd/appmgr/subscriptions.go
+++ b/
cmd/appmgr/subscriptions.go
@@
-36,6
+36,15
@@
func (sd *SubscriptionDispatcher) Initialize() {
}
func (sd *SubscriptionDispatcher) Add(sr SubscriptionReq) (resp SubscriptionResp) {
}
func (sd *SubscriptionDispatcher) Add(sr SubscriptionReq) (resp SubscriptionResp) {
+ // Skip duplicates
+ for v := range sd.subscriptions.IterBuffered() {
+ r := v.Val.(Subscription).req
+ if r.TargetUrl == sr.TargetUrl && r.EventType == sr.EventType {
+ Logger.Info("Similar subscription already exists!")
+ return
+ }
+ }
+
key := ksuid.New().String()
resp = SubscriptionResp{key, 0, sr.EventType}
sr.Id = key
key := ksuid.New().String()
resp = SubscriptionResp{key, 0, sr.EventType}
sr.Id = key
@@
-108,10
+117,10
@@
func (sd *SubscriptionDispatcher) notifyClients(xapps []Xapp, et EventType) {
func (sd *SubscriptionDispatcher) notify(xapps []Xapp, et EventType, s Subscription, seq int) error {
xappData, err := json.Marshal(xapps)
func (sd *SubscriptionDispatcher) notify(xapps []Xapp, et EventType, s Subscription, seq int) error {
xappData, err := json.Marshal(xapps)
-
if err != nil {
-
Logger.Info("json.Marshal failed: %v", err)
-
return err
-
}
+ if err != nil {
+ Logger.Info("json.Marshal failed: %v", err)
+ return err
+ }
notif := SubscriptionNotif{Id: s.req.Id, Version: seq, EventType: string(et), XApps: string(xappData)}
jsonData, err := json.Marshal(notif)
notif := SubscriptionNotif{Id: s.req.Id, Version: seq, EventType: string(et), XApps: string(xappData)}
jsonData, err := json.Marshal(notif)