udoprog / leaky-bucket

A token-based rate limiter based on the leaky bucket algorithm.
Apache License 2.0
93 stars 10 forks source link

Fix over-max implementation and documentation (relates #13) #14

Closed udoprog closed 2 years ago

udoprog commented 2 years ago

Current refill implementation was incorrectly implemented, so a maximum token retention of 0 would cause it to never wake up.

Here instead we fill up the number of tokens that are added each cycle and clamp it to max allowing the over-max example to work again.

Also adjusts the documentation for #13