Fix: rate allowance calculations should use seconds, not nanoseconds

Artyom Pervukhin 2015-02-04 16:22:04 +03:00
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