Skip to content

RateLimitStore

Defined in: packages/rest/src/store.ts:94

Interface for distributed or local rate limit synchronization.

readonly optional reservesGlobal?: boolean

Defined in: packages/rest/src/store.ts:131

Whether reserve also checks options.global atomically. When it does not, the limiter reads the global reset itself first.

optional extendGlobalReset(scope, waitMs): void | Promise<void>

Defined in: packages/rest/src/store.ts:145

Atomically extends a global limit to at least waitMs from now, never shortening a longer one. Optional: without it the limiter reads and writes, which a concurrent writer can shorten.

string

number

void | Promise<void>


getBucket(key): BucketState | Promise<BucketState | undefined> | undefined

Defined in: packages/rest/src/store.ts:103

Gets the current state for a bucket key.

string

BucketState | Promise<BucketState | undefined> | undefined


getBucketHash(route): string | Promise<string | undefined> | undefined

Defined in: packages/rest/src/store.ts:96

Gets the server bucket hash for a normalized route.

string

string | Promise<string | undefined> | undefined


getGlobalReset(scope?): number | Promise<number>

Defined in: packages/rest/src/store.ts:110

Gets the global reset timestamp (of scope, when the store keeps several).

string

number | Promise<number>


optional prune(maxAge?): void | Promise<void>

Defined in: packages/rest/src/store.ts:165

Evicts expired bucket entries. Optional: stores with native key expiry (e.g. Redis) can omit it. maxAge (ms) additionally drops buckets whose reset is older than that window; defaults to 0 (only already-reset buckets are removed).

number

void | Promise<void>


optional reconcile(key, update): void | Promise<void>

Defined in: packages/rest/src/store.ts:138

Atomically merges what a response said into a bucket, so a late or out-of-order response cannot hand back allowance already reserved. Optional: without it the limiter reads, merges and writes.

string

BucketUpdate

void | Promise<void>


optional release(key, grant, refund): void | Promise<void>

Defined in: packages/rest/src/store.ts:153

Gives back what a granted reservation held, when that is certain to be safe: a probe placeholder is cleared (so the next request may probe), and with refund — the request was never sent — the unit is returned to the window it came from, if that window is still current.

string

number

boolean

void | Promise<void>


optional reserve(key, options?): Reservation | Promise<Reservation>

Defined in: packages/rest/src/store.ts:122

Atomically consumes one unit of a bucket’s allowance.

Optional: a store that cannot do this atomically must omit it, and the limiter falls back to waiting on observed state. Implementations must never refuse forever: an unknown bucket is discovered by sending, so one caller (the probe) must be granted.

string

ReserveOptions

Reservation | Promise<Reservation>


setBucketHash(route, hash): void | Promise<void>

Defined in: packages/rest/src/store.ts:100

Associates a route with a server bucket hash.

string

string

void | Promise<void>


setGlobalReset(resetAt, scope?): void | Promise<void>

Defined in: packages/rest/src/store.ts:112

Sets the global reset timestamp (of scope, when the store keeps several).

number

string

void | Promise<void>


updateBucket(key, state): void | Promise<void>

Defined in: packages/rest/src/store.ts:107

Replaces the state for a bucket key.

string

BucketState

void | Promise<void>