async_limiter

Crates.ioasync_limiter
lib.rsasync_limiter
version0.1.3
created_at2025-04-24 18:26:13.483529+00
updated_at2025-04-24 18:54:25.256612+00
descriptionSimple ratelimiter for async tasks.
homepage
repositoryhttps://github.com/BerserkerMother/async_limiter
max_upload_size
id1647609
size6,463
Kave Bahraman (BerserkerMother)

documentation

https://docs.rs/async_limiter

README

async_limiter

Crates.io Documentation License

An asynchronous rate limiter for Rust based on the token bucket algorithm.

Installation

Add this to your Cargo.toml:

[dependencies]
async_limiter = "0.1"

Basic Usage

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();
    });
}

Contribution

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.

Commit count: 6

cargo fmt