limitr
limitr is a Rust crate that provides implementations of rate-limiting algorithms for controlling the rate of requests
or operations. It includes various algorithms such as Token Bucket and Leaky Bucket, which are commonly used to manage
and limit request rates in applications.
Features
- Token Bucket: Allows requests to be processed at a burst rate up to a certain capacity and then at a steady rate.
- Leaky Bucket: Ensures a steady rate of processing by "leaking" requests at a constant rate, regardless of incoming request burstiness.
Installation
Add limitr to your Cargo.toml:
[]
= { = "1.40.0", = ["full"] }
= "0.1.0"
Usage
Token Bucket
use TokenBucket;
use ;
use Rng;
async
Leaky Bucket
use LeakyBucket;
use ;
use Rng;
async
Features
The crate includes the following features:
bucket(default): Enables the Token Bucket and Leaky Bucket implementations.full: Includes additional features or configurations if needed.
To enable specific features, use:
[]
= ["feature_name"]
License
limitr is licensed under the MIT License. See the LICENSE file for more details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request to contribute to the project.