| Crates.io | async_limiter |
| lib.rs | async_limiter |
| version | 0.1.3 |
| created_at | 2025-04-24 18:26:13.483529+00 |
| updated_at | 2025-04-24 18:54:25.256612+00 |
| description | Simple ratelimiter for async tasks. |
| homepage | |
| repository | https://github.com/BerserkerMother/async_limiter |
| max_upload_size | |
| id | 1647609 |
| size | 6,463 |
An asynchronous rate limiter for Rust based on the token bucket algorithm.
Add this to your Cargo.toml:
[dependencies]
async_limiter = "0.1"
let limiter = RateLimiter::new(1000, Duration::from_secs(47));
for _ in 0..10000 {
let limiter = limiter.clone();
tokio::spawn(async move {
limiter.wait().await;
let body = reqwest::get("https://rickandmortyapi.com/api/episode/16")
.await
.unwrap()
.text()
.await
.unwrap();
});
}
I developed this simple package for my own use cases. I thought it may benefit others. If I missed something or you need a new feature, feel free to open an issue.