philiprehberger-token_bucket is a Ruby library designed to provide thread-safe token bucket rate limiting functionality. It addresses the need to control the rate of operations, such as requests or actions, within Ruby applications by regulating access through a configurable token bucket algorithm.
The library allows users to create token buckets with customizable capacity, refill rate, and refill strategy. Two refill strategies are supported: 'smooth', which provides continuous token refilling, and 'interval', which refills tokens in bursts at defined intervals. The API enables both blocking and non-blocking token consumption with methods like 'take', which blocks until the requested number of tokens are available, and 'try_take', which attempts to consume tokens without blocking. Additional features include querying the current token count, estimating wait times for token availability, and waiting for tokens with a timeout. The library also supports draining all tokens, resetting the bucket to full capacity, setting the token count directly, and dynamically adjusting both the refill rate and capacity at runtime. Users can inspect the state of a bucket through a frozen hash snapshot containing available tokens, capacity, refill rate, and strategy. Error handling is provided for invalid arguments and operations that exceed the bucket's capacity.
1 or higher. Installation can be accomplished by adding the gem to a Gemfile or installing it directly via the gem command. The project is open source and licensed under the MIT License.
This tool is intended for developers working in Ruby who need a flexible and thread-safe mechanism to implement rate limiting in their applications. Its configuration options and runtime adjustability make it suitable for a variety of use cases where precise control over operation rates is required.
philiprehberger-token_bucket sits in PulseGate's Other infrastructure category. It focuses on implementing efficient, thread-safe rate limiting in Ruby applications. It is built as an open-source project for ruby developers. The project is open source (MIT). It ships for the web and the command line, and it can be self-hosted.
Philip Rehberger builds and maintains philiprehberger-token_bucket, and it first shipped in 2014. Development happens publicly on GitHub with 7 commits in the last 90 days. Among its 5 catalogued features are token bucket algorithm, thread safety, and configurable capacity. It exposes integrations via a public API.
Summary written by a language model from the project’s public pages.
What PulseGate has recorded for this listing
Closest matches by what these projects do