Skip to content
Interfacetypesv0.14.4

IRateLimiter

Sliding-window rate limiting keyed by caller-built strings, available as core.rateLimiter.

Async so one interface spans the in-memory default and durable store backends. The in-memory implementation resolves synchronously, so the await costs no event-loop yield.

interface IRateLimiter

charge()

Records a use of key if the window has a free slot, in one atomic step.

charge(
    key: string,
    window: RateLimitWindow
): Promise<RateLimitResult>
Parameter: key

The bucket to charge. Build it from your own scope, or with buildKey from @seedcord/rate-limiter.

Parameter: window

The usage window to apply.

peek()

Reports key's limited state without recording a use.

The read half of a peek-then-commit. The Cooldown gate peeks in its check and charges in its commit, so a refusal elsewhere in the gate set never burns the slot.