Skip to content

Commit

Permalink
v2 clean up subscriptions
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <[email protected]>
  • Loading branch information
jzding committed Aug 14, 2024
1 parent d590098 commit a965167
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions v1/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ func (p *API) DeleteSubscription(clientID uuid.UUID, subscriptionID string) erro
return nil
}

// DeleteAllSubscriptions delete all subscriptionOne information
func (p *API) DeleteAllSubscriptions(clientID uuid.UUID) error {
// DeleteAllSubscriptionsForClient delete all subscriptionOne for the client
func (p *API) DeleteAllSubscriptionsForClient(clientID uuid.UUID) error {
if subStore, ok := p.SubscriberStore.Get(clientID); ok {
if err := deleteAllFromFile(fmt.Sprintf("%s/%s", p.storeFilePath, fmt.Sprintf("%s.json", clientID))); err != nil {
return err
Expand All @@ -343,6 +343,14 @@ func (p *API) DeleteAllSubscriptions(clientID uuid.UUID) error {
return nil
}

// DeleteAllSubscriptions delete all subscriptions in store
func (p *API) DeleteAllSubscriptions() error {
for clientID := range p.SubscriberStore.Store {
p.DeleteClient(clientID)
}
return nil
}

// DeleteClient delete all subscriptionOne information
func (p *API) DeleteClient(clientID uuid.UUID) error {
if _, ok := p.SubscriberStore.Get(clientID); ok { // client found
Expand Down

0 comments on commit a965167

Please sign in to comment.