gaato/discord/ratelimit does not have a README file

RateLimiter

pub(open) trait RateLimiter {
async fn acquire(Self, bucket_key : String, global_exempt~ : Bool) -> Unit
async fn release(Self, bucket_key : String, status~ : Int, headers~ : Map[String, String]) -> Unit
}

REST rate limiting strategy.

The design is requester-driven: acquire blocks (asynchronously) in the calling task until the request may proceed, and release must be called exactly once per successful acquire, with the response's rate-limit headers when available. There is no background actor task, so a cancelled caller cleans up naturally.

Implementations other than InMemoryRateLimiter (e.g. a cross-process store) can be plugged into the HTTP client via this trait.

InMemoryRateLimiter

pub struct InMemoryRateLimiter {
global_limit : Int
global_window_start : Int64
global_count : Int
global_blocked_until : Int64
// private fields
}

In-process RateLimiter: per-bucket accounting learned from response headers plus a global sliding-window limit (default 50 requests/second).

InMemoryRateLimiter::InMemoryRateLimiter

fn InMemoryRateLimiter::InMemoryRateLimiter(global_limit? : Int) -> InMemoryRateLimiter

Create a limiter with empty bucket accounting and a global window of global_limit requests per second.

Source Files