Skip to content

PartitionedRateLimiterOptions

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

T

optional control?: RateLimiterControl

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

Penalty / reward / block per key. The per-key limiters must be RateLimiterStrategys (fixed, sliding, token bucket). A block is lost if its partition is evicted, so keep idleTimeout >= the block.


optional idleTimeout?: Duration

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

A partition unused this long (and with nothing running) is dropped, resetting its limit. Default 10 minutes. Keep it at least as long as the limiter’s window, or an evicted partition gets a fresh quota early.


limiter: (key, source) => ResilienceStrategy<T>

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

Creates the limiter of a new partition, e.g. (key, s) => new SlidingWindowRateLimiterStrategy({ permitLimit: 100, window: '1m' }, s).

string

StrategySource

ResilienceStrategy<T>


optional maxPartitions?: number

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

Most partitions kept; past it the least recently used partition with nothing running is dropped (its limit resets). When all of them are running, a new key is rejected with RateLimiterRejectedError. Default: no limit.


optional name?: string

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


partitionKey: (context) => string

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

Which partition an execution counts against, e.g. (ctx) => ctx.properties.get('userId') as string.

ResilienceContext

string