Skip to content

FixedWindowRateLimiterOptions

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

optional alignment?: "fixed" | "first-request"

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

'fixed' (default): windows follow each other from the limiter’s creation. 'first-request': a window starts at the first request after the previous one ended (per partition, when partitioned).


optional allow?: (context) => boolean

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

Bypass the limiter, e.g. internal callers.

ResilienceContext

boolean

PermitRateLimiterOptions.allow


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).

PermitRateLimiterOptions.blockDuration


optional control?: RateLimiterControl

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

PermitRateLimiterOptions.control


optional deny?: (context) => boolean

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

Reject with RateLimiterDeniedError right away (checked before allow).

ResilienceContext

boolean

PermitRateLimiterOptions.deny


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

PermitRateLimiterOptions.insurance


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.

PermitRateLimiterOptions.minTime


optional name?: string

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

PermitRateLimiterOptions.name


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

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

OnRateLimiterRejectedArgs

MaybePromise<void>

PermitRateLimiterOptions.onRejected


permitLimit: number

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

Permits granted per window.


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

PermitRateLimiterOptions.permits


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.

PermitRateLimiterOptions.queueLimit


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.

PermitRateLimiterOptions.queueTimeout


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.

PermitRateLimiterOptions.spacing


window: Duration

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