Skip to content
Interfacetypesv0.16.0

IRateLimiter

Sliding-window rate limiting keyed by caller-built strings, available as core.rateLimiter. It saves its counts in config.kv.

interface IRateLimiter

charge()

Records a use of key if the window has a free slot. Charges on one key run one at a time in this process.

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

The bucket to charge. Build it from your own scope, or with buildKey.

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.