Skip to main content

LeakyBucket

@discordeno/bot


Documentation / @discordeno/bot / LeakyBucket

Class: LeakyBucket

Defined in: packages/utils/dist/types/bucket.d.ts:2

Implements

Constructors

new LeakyBucket()

new LeakyBucket(options?): LeakyBucket

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

Parameters

options?

LeakyBucketOptions

Returns

LeakyBucket

Properties

logger

logger: Pick<{ debug: (...args) => void; error: (...args) => void; fatal: (...args) => void; info: (...args) => void; log: (level, ...args) => void; setDepth: (level) => void; setLevel: (level) => void; warn: (...args) => void; }, "debug" | "info" | "warn" | "error" | "fatal">

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

Logger used in the leaky bucket

Implementation of

LeakyBucketOptions.logger


max

max: number

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

Max requests allowed at once.

Default

1

Implementation of

LeakyBucketOptions.max


processing

processing: boolean

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

Whether or not the queue is already processing.


queue

queue: (value) => void[]

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

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

Parameters

value

void | PromiseLike<void>

Returns

void


refillAmount

refillAmount: number

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

Amount of requests to refill at each interval.

Default

1

Implementation of

LeakyBucketOptions.refillAmount


refillInterval

refillInterval: number

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

Interval in milliseconds between refills.

Default

5000

Implementation of

LeakyBucketOptions.refillInterval


refillsAt?

optional refillsAt: number

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

The timestamp in milliseconds when the next refill is scheduled.


timeoutId?

optional timeoutId: Timeout

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

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


used

used: number

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

The amount of requests that have been used up already.

Accessors

remaining

Get Signature

get remaining(): number

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

The amount of requests that still remain.

Returns

number

Methods

acquire()

acquire(highPriority?): Promise<void>

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

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

Parameters

highPriority?

boolean

Returns

Promise<void>


processQueue()

processQueue(): Promise<void>

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

Begin processing the queue.

Returns

Promise<void>


refillBucket()

refillBucket(): void

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

Refills the bucket as needed.

Returns

void