Skip to content

Commit

Permalink
added comment for maxDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
mpl committed Jan 3, 2023
1 parent f354947 commit de25cde
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/middlewares/ratelimiter/rate_limiter.go
Expand Up @@ -79,9 +79,11 @@ func New(ctx context.Context, next http.Handler, config dynamic.RateLimit, name
period = time.Second
}

var maxDelay time.Duration
// Initialized at rate.Inf to enforce no rate limiting when config.Average == 0
rtl := float64(rate.Inf)
// No need to set any particular value for maxDelay as the reservation's delay
// will be <= 0 in the Inf case (i.e. the average == 0 case).
var maxDelay time.Duration

if config.Average > 0 {
rtl = float64(config.Average*int64(time.Second)) / float64(period)
Expand Down

0 comments on commit de25cde

Please sign in to comment.