Skip to main content

Crate token_bucket

Crate token_bucket 

Source
Expand description

token-bucket

Zero-dependency, lock-free atomic GCRA, Fixed-Window, Token-Bucket, and 64-way sharded bounded keyed rate-limiting engine.

Structs§

FixedWindowCell
Lock-free single-AtomicU64 fixed-window state cell packing (window_id, count).
FixedWindowConfig
Immutable configuration for a lock-free atomic fixed-window rate limiter.
FixedWindowLimiter
Lock-free atomic fixed-window rate limiter with an embedded monotonic clock.
GcraCell
Lock-free single-AtomicU64 GCRA state cell usable standalone or inside sharded maps.
GcraConfig
Immutable configuration for a GCRA (Generic Cell Rate Algorithm) limiter.
GcraLimiter
Lock-free atomic GCRA rate limiter with an embedded monotonic nanosecond clock.
KeyedRateLimiter
64-way cache-line-aligned sharded, bounded, lock-free-CAS keyed rate limiter.
MonotonicClock
Monotonic nanosecond clock anchored at limiter creation time.
RateLimitDecision
Outcome of a rate-limit evaluation with exact nanosecond reset and retry timings.
TokenBucketCell
Lock-free single-AtomicU64 token-bucket state cell packing (last_step, tokens).
TokenBucketConfig
Immutable configuration for a lock-free atomic token-bucket rate limiter.
TokenBucketLimiter
Lock-free atomic token-bucket rate limiter with an embedded monotonic clock.

Enums§

RateLimitError
Configuration validation errors returned by rate-limiter constructors.
RateLimitPolicy
Unified rate-limiting algorithm policy applied to every key in a KeyedRateLimiter.

Constants§

KEYED_SHARD_COUNT
Number of cache-line-aligned shards in KeyedRateLimiter.
MAX_FIXED_WINDOW_LIMIT
Maximum per-window request limit supported by single-atomic packed fixed-window state.
MAX_TOKEN_BUCKET_CAPACITY
Maximum token-bucket capacity supported by single-atomic packed state.