Skip to content

Commit

Permalink
fix subscription for multiple clients
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <jackding@gmail.com>
  • Loading branch information
jzding committed Dec 11, 2024
1 parent fc15be4 commit d79010d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@
# vendor/
cover.out
v1/subscriber/subscribers

.idea
.cache
.dccache

18 changes: 2 additions & 16 deletions v1/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,6 @@ func (p *API) GetSubscriberURLByResource(resource string) (urls []string) {
return urls
}

// GetClientIDByResource get subscriptionOne information
func (p *API) GetClientIDByResource(resource string) (clientIDs []uuid.UUID) {
p.SubscriberStore.RLock()
defer p.SubscriberStore.RUnlock()
for _, subs := range p.SubscriberStore.Store {
for _, sub := range subs.SubStore.Store {
if strings.Contains(sub.GetResource(), resource) {
clientIDs = append(clientIDs, subs.ClientID)
}
}
}
return clientIDs
}

// GetClientIDBySubID ...
func (p *API) GetClientIDBySubID(subID string) (clientIDs []uuid.UUID) {
p.SubscriberStore.RLock()
Expand All @@ -300,14 +286,14 @@ func (p *API) GetClientIDBySubID(subID string) (clientIDs []uuid.UUID) {
return clientIDs
}

// GetClientIDAddressByResource get subscriptionOne information
// GetClientIDAddressByResource get subscriptionOne information
func (p *API) GetClientIDAddressByResource(resource string) map[uuid.UUID]*types.URI {
clients := map[uuid.UUID]*types.URI{}
p.SubscriberStore.RLock()
defer p.SubscriberStore.RUnlock()
for _, subs := range p.SubscriberStore.Store {
for _, sub := range subs.SubStore.Store {
if sub.GetResource() == resource {
if strings.Contains(sub.GetResource(), resource) {
clients[subs.ClientID] = subs.EndPointURI
}
}
Expand Down

0 comments on commit d79010d

Please sign in to comment.