Skip to content

Commit

Permalink
fixed ratelimiter bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Jun 11, 2020
1 parent 33673c1 commit 66b2085
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/middlewares/canary/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
headerAuth = "Authorization"
headerUA = "User-Agent"
headerXCanary = "X-Canary"
headerXRequestID = "X-Request-ID"
headerXRequestID = "X-Request-Id"
defaultCacheSize = 100000
defaultExpiration = time.Minute * 10
defaultCacheCleanDuration = time.Minute * 20
Expand Down
2 changes: 1 addition & 1 deletion pkg/middlewares/ratelimiter/rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
bucket = rlSource.(*rate.Limiter)
} else {
bucket = rate.NewLimiter(rl.rate, int(rl.burst))
if err := rl.buckets.Set(source, bucket, int(rl.maxDelay)*10+1); err != nil {
if err := rl.buckets.Set(source, bucket, int(rl.maxDelay/time.Second)*10+1); err != nil {
logger.Errorf("could not insert bucket: %v", err)
http.Error(w, "could not insert bucket", http.StatusInternalServerError)
return
Expand Down

0 comments on commit 66b2085

Please sign in to comment.