Skip to main content

LeakyBucket

@discordeno/botDocs


Documentation / @discordeno/bot / LeakyBucket

Class: LeakyBucket

Implements

Constructors

new LeakyBucket()

new LeakyBucket(options?): LeakyBucket

Parameters

options?: LeakyBucketOptions

Returns

LeakyBucket

Defined in

packages/utils/dist/types/bucket.d.ts:18

Properties

logger

logger: Pick<object, "debug" | "info" | "warn" | "error" | "fatal">

Logger used in the leaky bucket

Type declaration

debug()

debug: (...args) => void

Parameters

• ...args: any[]

Returns

void

error()

error: (...args) => void

Parameters

• ...args: any[]

Returns

void

fatal()

fatal: (...args) => void

Parameters

• ...args: any[]

Returns

void

info()

info: (...args) => void

Parameters

• ...args: any[]

Returns

void

log()

log: (level, ...args) => void

Parameters

level: LogLevels

• ...args: any[]

Returns

void

setDepth()

setDepth: (level) => void

Parameters

level: LogDepth

Returns

void

setLevel()

setLevel: (level) => void

Parameters

level: LogLevels

Returns

void

warn()

warn: (...args) => void

Parameters

• ...args: any[]

Returns

void

Implementation of

LeakyBucketOptions.logger

Defined in

packages/utils/dist/types/bucket.d.ts:17


max

max: number

Max requests allowed at once.

Default

1

Implementation of

LeakyBucketOptions.max

Defined in

packages/utils/dist/types/bucket.d.ts:3


processing

processing: boolean

Whether or not the queue is already processing.

Defined in

packages/utils/dist/types/bucket.d.ts:11


queue

queue: (value) => void[]

The queue of requests to acquire an available request. Mapped by <shardId, resolve()>

Defined in

packages/utils/dist/types/bucket.d.ts:9


refillAmount

refillAmount: number

Amount of requests to refill at each interval.

Default

1

Implementation of

LeakyBucketOptions.refillAmount

Defined in

packages/utils/dist/types/bucket.d.ts:5


refillInterval

refillInterval: number

Interval in milliseconds between refills.

Default

5000

Implementation of

LeakyBucketOptions.refillInterval

Defined in

packages/utils/dist/types/bucket.d.ts:4


refillsAt?

optional refillsAt: number

The timestamp in milliseconds when the next refill is scheduled.

Defined in

packages/utils/dist/types/bucket.d.ts:15


timeoutId?

optional timeoutId: Timeout

The timeout id for the timer to reduce the used amount by the refill amount.

Defined in

packages/utils/dist/types/bucket.d.ts:13


used

used: number

The amount of requests that have been used up already.

Defined in

packages/utils/dist/types/bucket.d.ts:7

Accessors

remaining

Get Signature

get remaining(): number

The amount of requests that still remain.

Returns

number

Defined in

packages/utils/dist/types/bucket.d.ts:20

Methods

acquire()

acquire(highPriority?): Promise<void>

Pauses the execution until the request is available to be made.

Parameters

highPriority?: boolean

Returns

Promise<void>

Defined in

packages/utils/dist/types/bucket.d.ts:26


processQueue()

processQueue(): Promise<void>

Begin processing the queue.

Returns

Promise<void>

Defined in

packages/utils/dist/types/bucket.d.ts:24


refillBucket()

refillBucket(): void

Refills the bucket as needed.

Returns

void

Defined in

packages/utils/dist/types/bucket.d.ts:22