From 2aa580b3926a1212ac5a2f1778308dde2c1059d8 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Sun, 29 Sep 2024 12:05:31 +0800 Subject: [PATCH] fix metrics Signed-off-by: Ryan Leung --- pkg/ratelimit/limiter.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/ratelimit/limiter.go b/pkg/ratelimit/limiter.go index 1263fa3b2704..e312066dc565 100644 --- a/pkg/ratelimit/limiter.go +++ b/pkg/ratelimit/limiter.go @@ -41,7 +41,10 @@ type limiter struct { } func newLimiter() *limiter { - return &limiter{} + lim := &limiter{ + concurrency: NewConcurrencyLimiter(0), + } + return lim } func (l *limiter) getConcurrencyLimiter() *ConcurrencyLimiter { @@ -57,7 +60,7 @@ func (l *limiter) getRateLimiter() *RateLimiter { } func (l *limiter) isEmpty() bool { - return l.concurrency == nil && l.rate == nil + return (l.concurrency == nil || l.concurrency.limit == 0) && l.rate == nil } func (l *limiter) getQPSLimiterStatus() (limit rate.Limit, burst int) { @@ -86,7 +89,7 @@ func (l *limiter) updateConcurrencyConfig(limit uint64) UpdateStatus { defer l.mu.Unlock() if l.concurrency != nil { if limit < 1 { - l.concurrency = nil + l.concurrency = NewConcurrencyLimiter(0) if l.isEmpty() { return LimiterDeleted }