PartitionedRateLimiterStrategy
Defined in: src/window-rate-limiter.ts:684
One limiter per key (user, tenant, API key), so one noisy key can’t use up the others’ quota.
Type Parameters
Section titled “Type Parameters”T
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PartitionedRateLimiterStrategy<
T>(options,source):PartitionedRateLimiterStrategy<T>
Defined in: src/window-rate-limiter.ts:691
Parameters
Section titled “Parameters”options
Section titled “options”PartitionedRateLimiterOptions<T>
source
Section titled “source”Returns
Section titled “Returns”PartitionedRateLimiterStrategy<T>
Accessors
Section titled “Accessors”partitions
Section titled “partitions”Get Signature
Section titled “Get Signature”get partitions():
number
Defined in: src/window-rate-limiter.ts:701
Partitions currently held in memory.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”block()
Section titled “block()”block(
duration,key?):void
Defined in: src/window-rate-limiter.ts:737
Parameters
Section titled “Parameters”duration
Section titled “duration”string
Returns
Section titled “Returns”void
delete()
Section titled “delete()”delete(
key?):boolean
Defined in: src/window-rate-limiter.ts:711
Drops the partition of key (every partition when omitted): it starts over with a fresh quota and no block.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
execute()
Section titled “execute()”execute(
next,context):Promise<Outcome<T,unknown>>
Defined in: src/window-rate-limiter.ts:745
Parameters
Section titled “Parameters”Next<T>
context
Section titled “context”Returns
Section titled “Returns”Promise<Outcome<T, unknown>>
Implementation of
Section titled “Implementation of”keys()
Section titled “keys()”keys():
string[]
Defined in: src/window-rate-limiter.ts:706
Keys of the partitions held in memory, least recently used first.
Returns
Section titled “Returns”string[]
penalty()
Section titled “penalty()”penalty(
points,key?):Promise<void>
Defined in: src/window-rate-limiter.ts:729
Parameters
Section titled “Parameters”points
Section titled “points”number
string
Returns
Section titled “Returns”Promise<void>
restore()
Section titled “restore()”restore(
snapshot):void
Defined in: src/window-rate-limiter.ts:724
Recreates the partitions of a snapshot() (still bounded by maxPartitions) and loads their state.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”PartitionedRateLimiterSnapshot
Returns
Section titled “Returns”void
reward()
Section titled “reward()”reward(
points,key?):Promise<void>
Defined in: src/window-rate-limiter.ts:733
Parameters
Section titled “Parameters”points
Section titled “points”number
string
Returns
Section titled “Returns”Promise<void>
snapshot()
Section titled “snapshot()”snapshot(
limit?):PartitionedRateLimiterSnapshot
Defined in: src/window-rate-limiter.ts:718
Snapshots of the limit most recently used partitions (default all), for restore after a restart.
Parameters
Section titled “Parameters”limit?
Section titled “limit?”number = Infinity
Returns
Section titled “Returns”PartitionedRateLimiterSnapshot
unblock()
Section titled “unblock()”unblock(
key?):void
Defined in: src/window-rate-limiter.ts:741
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void