Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
prefer defer
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari committed Feb 19, 2024
1 parent d14b32e commit bbb7e7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions global.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (gm *globalManager) QueueUpdate(r *RateLimitReq) {
// be sent to their owning peers.
func (gm *globalManager) runAsyncHits() {
var interval = NewInterval(gm.conf.GlobalSyncWait)
defer interval.Stop()
hits := make(map[string]*RateLimitReq)

gm.wg.Until(func(done chan struct{}) bool {
Expand Down Expand Up @@ -116,7 +117,6 @@ func (gm *globalManager) runAsyncHits() {
hits = make(map[string]*RateLimitReq)
}
case <-done:
interval.Stop()
return false
}
return true
Expand Down Expand Up @@ -174,6 +174,7 @@ func (gm *globalManager) sendHits(hits map[string]*RateLimitReq) {
// runBroadcasts collects status changes for global rate limits and broadcasts the changes to each peer in the cluster.
func (gm *globalManager) runBroadcasts() {
var interval = NewInterval(gm.conf.GlobalSyncWait)
defer interval.Stop()
updates := make(map[string]*RateLimitReq)

gm.wg.Until(func(done chan struct{}) bool {
Expand Down Expand Up @@ -204,7 +205,6 @@ func (gm *globalManager) runBroadcasts() {
gm.metricGlobalQueueLength.Set(0)
}
case <-done:
interval.Stop()
return false
}
return true
Expand Down

0 comments on commit bbb7e7a

Please sign in to comment.