Registry / networking / leaky-bucket

leaky-bucket

JSON →
library1.1.2rscratesunverified

A token-based rate limiter implementing the leaky bucket algorithm.

# Cargo.toml [dependencies] leaky-bucket = "1.1.2"
INSTALL
IMPORT
SIG · LEAKY-BUCKET
L
leaky-bucket
networkingrustv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LeakyBucket
use leaky_bucket::LeakyBucket;

Create a leaky bucket rate limiter and acquire a token.

use leaky_bucket::LeakyBucket; use std::time::Duration; #[tokio::main] async fn main() { let bucket = LeakyBucket::builder() .max(10) .tokens(5) .refill_interval(Duration::from_secs(1)) .build(); bucket.acquire().await; println!("Acquired token"); }
Debug
Known issues
gotchaRequires an async runtime (e.g., Tokio) for the acquire method.
fix
Add tokio as a dependency and use #[tokio::main].
affects: >=1.0.0
Upgrade
Version history
1.1.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
26
Resources
leaky-bucket — cargo add leaky-bucket · libregistry