Crates.io | reqwest-leaky-bucket |
lib.rs | reqwest-leaky-bucket |
version | 0.2.0 |
source | src |
created_at | 2023-09-29 17:46:25.764076 |
updated_at | 2024-05-19 13:34:58.137513 |
description | Leaky-bucket rate limit middleware for reqwest. |
homepage | |
repository | https://github.com/xDarksome/reqwest-leaky-bucket |
max_upload_size | |
id | 987654 |
size | 5,331 |
leaky-bucket
rate-limit middleware implementation for
reqwest-middleware
based on
reqwest-ratelimit
.
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();
}