Skip to content

Commit

Permalink
fix metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Sep 29, 2024
1 parent 87b93a7 commit 2aa580b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/ratelimit/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ type limiter struct {
}

func newLimiter() *limiter {
return &limiter{}
lim := &limiter{
concurrency: NewConcurrencyLimiter(0),
}
return lim
}

func (l *limiter) getConcurrencyLimiter() *ConcurrencyLimiter {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2aa580b

Please sign in to comment.