Skip to content

Commit

Permalink
pull events only when subscribed
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <jackding@gmail.com>
  • Loading branch information
jzding committed Jul 29, 2024
1 parent e6c7d98 commit 104812f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion v2/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) {
respondWithError(w, "resourceAddress can not be empty")
return
}

//identify publisher or subscriber is asking for status
var sub *pubsub.PubSub
if len(s.pubSubAPI.GetSubscriptions()) > 0 {
Expand All @@ -449,13 +450,19 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) {
}

if sub == nil {
respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscription not found for %s", resourceAddress))
respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscriptions not found for %s", resourceAddress))
return
}

if !strings.HasPrefix(resourceAddress, "/") {
resourceAddress = fmt.Sprintf("/%s", resourceAddress)
}
eventSubscribers := s.subscriberAPI.GetClientIDAddressByResource(resourceAddress)
if len(eventSubscribers) == 0 {
respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscription not found for %s", resourceAddress))
return
}

// this is placeholder not sending back to report
out := channel.DataChan{
Address: resourceAddress,
Expand Down

0 comments on commit 104812f

Please sign in to comment.