RateLimitStore
Defined in: packages/rest/src/store.ts:94
Interface for distributed or local rate limit synchronization.
Properties
Section titled “Properties”reservesGlobal?
Section titled “reservesGlobal?”
readonlyoptionalreservesGlobal?: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.
Methods
Section titled “Methods”extendGlobalReset()?
Section titled “extendGlobalReset()?”
optionalextendGlobalReset(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.
Parameters
Section titled “Parameters”string
waitMs
Section titled “waitMs”number
Returns
Section titled “Returns”void | Promise<void>
getBucket()
Section titled “getBucket()”getBucket(
key):BucketState|Promise<BucketState|undefined> |undefined
Defined in: packages/rest/src/store.ts:103
Gets the current state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”BucketState | Promise<BucketState | undefined> | undefined
getBucketHash()
Section titled “getBucketHash()”getBucketHash(
route):string|Promise<string|undefined> |undefined
Defined in: packages/rest/src/store.ts:96
Gets the server bucket hash for a normalized route.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | Promise<string | undefined> | undefined
getGlobalReset()
Section titled “getGlobalReset()”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).
Parameters
Section titled “Parameters”scope?
Section titled “scope?”string
Returns
Section titled “Returns”number | Promise<number>
prune()?
Section titled “prune()?”
optionalprune(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).
Parameters
Section titled “Parameters”maxAge?
Section titled “maxAge?”number
Returns
Section titled “Returns”void | Promise<void>
reconcile()?
Section titled “reconcile()?”
optionalreconcile(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.
Parameters
Section titled “Parameters”string
update
Section titled “update”Returns
Section titled “Returns”void | Promise<void>
release()?
Section titled “release()?”
optionalrelease(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.
Parameters
Section titled “Parameters”string
resetAt?
Section titled “resetAt?”number
refund
Section titled “refund”boolean
Returns
Section titled “Returns”void | Promise<void>
reserve()?
Section titled “reserve()?”
optionalreserve(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.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Reservation | Promise<Reservation>
setBucketHash()
Section titled “setBucketHash()”setBucketHash(
route,hash):void|Promise<void>
Defined in: packages/rest/src/store.ts:100
Associates a route with a server bucket hash.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void | Promise<void>
setGlobalReset()
Section titled “setGlobalReset()”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).
Parameters
Section titled “Parameters”resetAt
Section titled “resetAt”number
scope?
Section titled “scope?”string
Returns
Section titled “Returns”void | Promise<void>
updateBucket()
Section titled “updateBucket()”updateBucket(
key,state):void|Promise<void>
Defined in: packages/rest/src/store.ts:107
Replaces the state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void | Promise<void>