Interface LimiterOptions

Represents the limiter options

interface LimiterOptions {
    autoStart?: boolean;
    bucketSize?: number;
    concurrency?: number;
    delay?: number;
    highWater?: number;
    interval?: number;
    penalty?: number;
    retryOptions?: RetryOptions;
    strategy?: Strategy;
    tokensPerInterval?: number;
}

Hierarchy (View Summary)

Properties

autoStart?: boolean

Set whether the limiter should start to process the jobs automatically

true
bucketSize?: number

Set the bucket size for the rate limiter

0 If the bucket size is 0, only concurrency and delay will be used to limit the rate of the jobs. If the bucket size is greater than 0, the consumption of the tokens will be used to limit the rate of the jobs. The bucket size is the maximum number of tokens that can be consumed in the interval. The interval is defined by the tokensPerInterval and interval properties.

concurrency?: number

The maximum number of concurrent jobs

1
delay?: number

Delay between each job in milliseconds

0 For concurrency = 1, the delay is applied after each job is finished For concurrency > 1, if the actual number of concurrent jobs is less than concurrency, the delay is applied after each job is finished, otherwise, the delay is applied after each job is started.

highWater?: number

The maximum number of jobs in the queue

Infinity
interval?: number

Define the interval in milliseconds

1000
penalty?: number

The penalty for the BLOCK strategy in milliseconds

0
retryOptions?: RetryOptions

Set the default options for the retry process of the jobs

undefined
strategy?: Strategy

The strategy to use when the queue length reaches highWater

'leak'
tokensPerInterval?: number

Define the number of tokens that will be added to the bucket at the beginning of the interval

1