mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Fix: rate allowance calculations should use seconds, not nanoseconds
parent
db54ef400b
commit
489961baba
@ -99,7 +99,7 @@ func (r *Ratelimiter) Limit() bool {
|
||||
now := time.Now()
|
||||
elapsed := now.Sub(r.last)
|
||||
r.last = now
|
||||
r.allowance += float64(elapsed) * rate
|
||||
r.allowance += elapsed.Seconds() * rate
|
||||
|
||||
// Clamp number of tokens in the bucket. Don't let it get
|
||||
// unboundedly large
|
||||
|
Loading…
x
Reference in New Issue
Block a user