Created a new limiter, and attempted to take a token at t=0:
l := rate.NewLimiter(1, 1)
l.AllowN(time.Time{}, 1)
What did you expect to see?
AllowN(...any time..., 1) should succeed if the token bucket is initially full as documented.
What did you see instead?
AllowN returns false
It appears that the token bucket is not initially full.
The limiter depends on the elapsed time from the zero value of last to the value of now the first time AllowN is called being long enough to fill the bucket.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.9.2
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Created a new limiter, and attempted to take a token at t=0:
What did you expect to see?
AllowN(...any time..., 1)
should succeed if the token bucket is initially full as documented.What did you see instead?
AllowN
returns falseIt appears that the token bucket is not initially full.
The limiter depends on the elapsed time from the zero value of
last
to the value ofnow
the first time AllowN is called being long enough to fill the bucket.