async/rate_limiter_utils library
Token-bucket rate limiter — roadmap #670.
Smooths a burst of work to a sustainable average rate: tokens refill
continuously at tokensPerSecond up to a capacity (the burst ceiling), and
each unit of work spends tokens. This is the non-blocking core primitive —
tryAcquire returns allow/deny immediately and timeUntilAvailable says how
long until a denied request would succeed, so the caller decides whether to
drop, queue, or delay. No Timer and no wall-clock coupling: time is read
through an injectable now closure, making refill behavior fully
deterministic under test.
Classes
- TokenBucketRateLimiter
-
A token bucket:
capacitytokens max, refilling attokensPerSecond.