RateLimiter
RateLimiter =
object
Defined in: Core/RateLimiter.ts:24
Paces fallible work against a sliding-window quota.
A call is admitted while fewer than limit calls have started in the last window. Beyond that,
the default "wait" strategy queues the call and starts it when the oldest admitted call expires;
"reject" settles immediately with RateLimiter.LimitError carrying retryAfterMs.
Example
Section titled “Example”Properties
Section titled “Properties”available
Section titled “available”
readonlyavailable: () =>number
Defined in: Core/RateLimiter.ts:47
Returns how many calls may start right now, between 0 and limit.
Returns
Section titled “Returns”number
readonlyreset: () =>void
Defined in: Core/RateLimiter.ts:57
Forgets the recorded window and admits every queued caller in submission order.
Intended for tests and operational overrides: it deliberately allows more than limit calls
to have started inside one window.
Returns
Section titled “Returns”void
RateLimiter.available to inspect the window instead of clearing it.
readonlyrun: {<E,A>(task):Deferred<Result<E|LimitError,A>>; <E,A>(task,options):Deferred<Result<Aborted|LimitError|E,A>>; }
Defined in: Core/RateLimiter.ts:36
Starts a fallible task when the quota allows it.
The task is lazy, so it does not start before a permit exists. With the "wait" strategy the
returned deferred settles once the task does; with "reject" it settles immediately with
RateLimiter.LimitError.
Call Signature
Section titled “Call Signature”<
E,A>(task):Deferred<Result<E|LimitError,A>>
Type Parameters
Section titled “Type Parameters”E
A
Parameters
Section titled “Parameters”Result<E, A>
Returns
Section titled “Returns”Deferred<Result<E | LimitError, A>>
Call Signature
Section titled “Call Signature”<
E,A>(task,options):Deferred<Result<Aborted|LimitError|E,A>>
Type Parameters
Section titled “Type Parameters”E
A
Parameters
Section titled “Parameters”Result<E, A>
options
Section titled “options”signal
Section titled “signal”AbortSignal
Returns
Section titled “Returns”Deferred<Result<Aborted | LimitError | E, A>>
task
The fallible work to run under the quota.
options
Optional cancellation. Aborting a queued call removes it without using a permit.
RateLimiter.available to read the remaining permits.