PartitionedRateLimiterOptions
Defined in: src/window-rate-limiter.ts:657
Type Parameters
Section titled “Type Parameters”T
Properties
Section titled “Properties”control?
Section titled “control?”
optionalcontrol?: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.
idleTimeout?
Section titled “idleTimeout?”
optionalidleTimeout?: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
Section titled “limiter”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).
Parameters
Section titled “Parameters”string
source
Section titled “source”Returns
Section titled “Returns”maxPartitions?
Section titled “maxPartitions?”
optionalmaxPartitions?: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.
optionalname?:string
Defined in: src/window-rate-limiter.ts:658
partitionKey
Section titled “partitionKey”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.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”string