reqwest-leaky-bucket

Crates.ioreqwest-leaky-bucket
lib.rsreqwest-leaky-bucket
version0.2.0
sourcesrc
created_at2023-09-29 17:46:25.764076
updated_at2024-05-19 13:34:58.137513
descriptionLeaky-bucket rate limit middleware for reqwest.
homepage
repositoryhttps://github.com/xDarksome/reqwest-leaky-bucket
max_upload_size
id987654
size5,331
(xDarksome)

documentation

README

reqwest-leaky-bucket

leaky-bucket rate-limit middleware implementation for reqwest-middleware based on reqwest-ratelimit.

Crates.io Docs.rs

Usage

use async_trait::async_trait;
use reqwest_leaky_bucket::leaky_bucket::RateLimiter;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};

async fn run() {
    let limiter = RateLimiter::builder().max(10).initial(0).refill(5).build();
    let client = ClientBuilder::new(reqwest::Client::new())
        .with(reqwest_leaky_bucket::rate_limit_all(limiter))
        .build();
    client.get("https://crates.io").send().await.unwrap();
}
Commit count: 5

cargo fmt