-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Rate limiter
TokenBucket::auto_replenish()
Frequently calling `auto_replenish` will reset `self.last_update` each time and `tokens` may be a fractional value (0 since it is a `u64`), in this case no tokens will replenished. To avoid this we only update `self.last_update` when `tokens > 0`. Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
- Loading branch information
1 parent
b790195
commit 87575cf
Showing
1 changed file
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters