TokenBucketOptions
Defined in: src/rate-limiter.ts:40
Extends
Section titled “Extends”Properties
Section titled “Properties”allow?
Section titled “allow?”
optionalallow?: (context) =>boolean
Defined in: src/window-rate-limiter.ts:328
Bypass the limiter, e.g. internal callers.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.allow
blockDuration?
Section titled “blockDuration?”
optionalblockDuration?: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).
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.blockDuration
control?
Section titled “control?”
optionalcontrol?:RateLimiterControl
Defined in: src/window-rate-limiter.ts:331
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.control
optionaldeny?: (context) =>boolean
Defined in: src/window-rate-limiter.ts:330
Reject with RateLimiterDeniedError right away (checked before allow).
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”insurance?
Section titled “insurance?”
optionalinsurance?: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
Section titled “algorithm”algorithm:
RateLimiterAlgorithm
timeout?
Section titled “timeout?”
optionaltimeout?:Duration
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.insurance
minTime?
Section titled “minTime?”
optionalminTime?: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.
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.minTime
optionalname?:string
Defined in: src/window-rate-limiter.ts:306
Inherited from
Section titled “Inherited from”onRejected?
Section titled “onRejected?”
optionalonRejected?: (args) =>MaybePromise<void>
Defined in: src/window-rate-limiter.ts:307
Parameters
Section titled “Parameters”Returns
Section titled “Returns”MaybePromise<void>
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.onRejected
permits?
Section titled “permits?”
optionalpermits?: (context) =>number
Defined in: src/window-rate-limiter.ts:320
Weight of an execution (e.g. batch size, cost). Default 1.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.permits
queueLimit?
Section titled “queueLimit?”
optionalqueueLimit?: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.
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.queueLimit
queueTimeout?
Section titled “queueTimeout?”
optionalqueueTimeout?: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.
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.queueTimeout
replenishmentPeriod
Section titled “replenishmentPeriod”replenishmentPeriod:
Duration
Defined in: src/rate-limiter.ts:44
Refill interval.
spacing?
Section titled “spacing?”
optionalspacing?:"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.
Inherited from
Section titled “Inherited from”PermitRateLimiterOptions.spacing
tokenLimit
Section titled “tokenLimit”tokenLimit:
number
Defined in: src/rate-limiter.ts:42
Bucket size (largest burst), and the number of tokens it starts with.
tokensPerPeriod?
Section titled “tokensPerPeriod?”
optionaltokensPerPeriod?:number
Defined in: src/rate-limiter.ts:46
Tokens added per period. Default tokenLimit.