Skip to content

SlidingWindowRateLimiterOptions

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

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

FixedWindowRateLimiterOptions.alignment


optional allow?: (context) => boolean

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

Bypass the limiter, e.g. internal callers.

ResilienceContext

boolean

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

FixedWindowRateLimiterOptions.blockDuration


optional control?: RateLimiterControl

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

FixedWindowRateLimiterOptions.control


optional deny?: (context) => boolean

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

Reject with RateLimiterDeniedError right away (checked before allow).

ResilienceContext

boolean

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

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

FixedWindowRateLimiterOptions.minTime


optional name?: string

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

FixedWindowRateLimiterOptions.name


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

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

OnRateLimiterRejectedArgs

MaybePromise<void>

FixedWindowRateLimiterOptions.onRejected


permitLimit: number

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

Permits granted per window.

FixedWindowRateLimiterOptions.permitLimit


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

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

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

FixedWindowRateLimiterOptions.queueTimeout


optional segmentsPerWindow?: number

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

Buckets the window slides by. More = smoother and more exact, at O(segments) per call. Default 10.


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.

FixedWindowRateLimiterOptions.spacing


window: Duration

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

FixedWindowRateLimiterOptions.window