From 0b2adf6622b918648b243d4bd16ec936067bd66d Mon Sep 17 00:00:00 2001 From: Shawn Poulson Date: Wed, 13 Mar 2024 10:57:36 -0400 Subject: [PATCH] Revert optimization that won't work. --- algorithms.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/algorithms.go b/algorithms.go index 8f4bea6a..c9231610 100644 --- a/algorithms.go +++ b/algorithms.go @@ -146,18 +146,18 @@ func tokenBucket(ctx context.Context, s Store, c Cache, r *RateLimitReq, reqStat rl.ResetTime = expire } - // Client is only interested in retrieving the current status or - // updating the rate limit config. - if r.Hits == 0 { - return rl, nil - } - if s != nil && reqState.IsOwner { defer func() { s.OnChange(ctx, r, item) }() } + // Client is only interested in retrieving the current status or + // updating the rate limit config. + if r.Hits == 0 { + return rl, nil + } + // If we are already at the limit. if rl.Remaining == 0 && r.Hits > 0 { trace.SpanFromContext(ctx).AddEvent("Already over the limit")