Skip to content
Buy me a coffee

PermitRateLimiterOptions

Defined in: src/window-rate-limiter.ts:318

  • RejectionOptions

optional allow?: (context) => boolean

Defined in: src/window-rate-limiter.ts:328

Bypass the limiter, e.g. internal callers.

ResilienceContext

boolean


optional blockDuration?: Duration

Defined in: src/window-rate-limiter.ts:326

Once an execution is rejected for exceeding the limit, reject everything for this long (brute-force protection).


optional control?: RateLimiterControl

Defined in: src/window-rate-limiter.ts:331


optional deny?: (context) => boolean

Defined in: src/window-rate-limiter.ts:330

Reject with RateLimiterDeniedError right away (checked before allow).

ResilienceContext

boolean


optional insurance?: object

Defined in: src/window-rate-limiter.ts:336

In-memory fallback for a remote algorithm: when acquire throws or exceeds timeout, algorithm answers instead and OnRateLimiterInsuranceUsed is reported. Size it per process (e.g. the shared limit / instances).

algorithm: RateLimiterAlgorithm

optional timeout?: Duration


optional minTime?: Duration

Defined in: src/window-rate-limiter.ts:343

Least time between the starts of two granted executions (bottleneck’s minTime); also the floor of 'even' spacing.


optional name?: string

Defined in: src/window-rate-limiter.ts:306

RejectionOptions.name


optional onRejected?: (args) => MaybePromise<void>

Defined in: src/window-rate-limiter.ts:307

OnRateLimiterRejectedArgs

MaybePromise<void>

RejectionOptions.onRejected


optional permits?: (context) => number

Defined in: src/window-rate-limiter.ts:320

Weight of an execution (e.g. batch size, cost). Default 1.

ResilienceContext

number


optional queueLimit?: number

Defined in: src/window-rate-limiter.ts:324

Most executions waiting (with queueTimeout); beyond it they are rejected at once. Default: no limit, as queueTimeout (default 0) already decides whether anyone waits.


optional queueTimeout?: Duration

Defined in: src/window-rate-limiter.ts:322

Longest an execution may wait for permits before it is rejected. Waiters are served first come, first served. Default 0: reject right away.


optional spacing?: "even"

Defined in: src/window-rate-limiter.ts:341

'even': delays granted executions so the quota left is spread evenly until the limit resets, instead of bursting at the start of the window. The delay counts against queueTimeout when that is set; abort ends it.