From 10f94ffcc26422d089639f46a74e4949c9fe8c87 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Tue, 11 Oct 2022 22:56:12 +0800 Subject: [PATCH] chore: remove unnecessary code (#2499) --- core/limit/tokenlimit.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/core/limit/tokenlimit.go b/core/limit/tokenlimit.go index 7e43e6db..a0f48f31 100644 --- a/core/limit/tokenlimit.go +++ b/core/limit/tokenlimit.go @@ -106,13 +106,6 @@ func (lim *TokenLimiter) AllowNCtx(ctx context.Context, now time.Time, n int) bo } func (lim *TokenLimiter) reserveN(ctx context.Context, now time.Time, n int) bool { - select { - case <-ctx.Done(): - logx.Errorf("fail to use rate limiter: %s", ctx.Err()) - return false - default: - } - if atomic.LoadUint32(&lim.redisAlive) == 0 { return lim.rescueLimiter.AllowN(now, n) } @@ -134,12 +127,10 @@ func (lim *TokenLimiter) reserveN(ctx context.Context, now time.Time, n int) boo if err == redis.Nil { return false } - if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) { logx.Errorf("fail to use rate limiter: %s", err) return false } - if err != nil { logx.Errorf("fail to use rate limiter: %s, use in-process limiter for rescue", err) lim.startMonitor()