Skip to content

Commit

Permalink
UPdate rest api to support configmap d delete all subscriber (#63)
Browse files Browse the repository at this point in the history
Signed-off-by: Aneesh Puttur <[email protected]>
  • Loading branch information
aneeshkp authored Apr 17, 2023
1 parent edf9a81 commit 46717e1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,25 @@ func (s *Server) createPublisher(w http.ResponseWriter, r *http.Request) {
func (s *Server) sendOut(eType channel.Type, sub *pubsub.PubSub) {
// go ahead and create QDR to this address
s.dataOut <- &channel.DataChan{
ID: sub.GetID(),
Address: sub.GetResource(),
Data: &ce.Event{},
Type: eType,
Status: channel.NEW,
}
}

func (s *Server) sendOutToDelete(eType channel.Type, sub *pubsub.PubSub) {
// go ahead and create QDR to this address
s.dataOut <- &channel.DataChan{
ID: sub.GetID(),
Address: sub.GetResource(),
Data: &ce.Event{},
Type: eType,
Status: channel.DELETE,
}
}

func (s *Server) getSubscriptionByID(w http.ResponseWriter, r *http.Request) {
queries := mux.Vars(r)
subscriptionID, ok := queries["subscriptionid"]
Expand Down Expand Up @@ -257,6 +269,8 @@ func (s *Server) deleteAllSubscriptions(w http.ResponseWriter, r *http.Request)
if size > 0 {
localmetrics.UpdateSubscriptionCount(localmetrics.ACTIVE, -(size))
}
// go ahead and create QDR to this address
s.sendOutToDelete(channel.SUBSCRIBER, &pubsub.PubSub{ID: "", Resource: "delete-all-subscriptions"})
respondWithMessage(w, http.StatusOK, "deleted all subscriptions")
}

Expand Down

0 comments on commit 46717e1

Please sign in to comment.