hoshii / Exports / SequentialBucket

SequentialBucket

A sequential bucket for ratelimits

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new SequentialBucket(limit, latencyRef)

Parameters

NameType
limitnumber
latencyRefLatencyRef

Defined in

lib/utils/SequentialBucket.ts:42open in new window

Properties

_queue

Private _queue: (cd: () => void) => void[]

The queue of functions to be executed

Defined in

lib/utils/SequentialBucket.ts:10open in new window


last

last: number

Timestamp of last token consumption

Defined in

lib/utils/SequentialBucket.ts:15open in new window


latencyRef

latencyRef: LatencyRef

A reference to the latency of the client

Defined in

lib/utils/SequentialBucket.ts:20open in new window


limit

limit: number

The maximum number of tokens per interval

Defined in

lib/utils/SequentialBucket.ts:25open in new window


processing

processing: boolean | Timeout

Whether the queue is currently being processed

Defined in

lib/utils/SequentialBucket.ts:30open in new window


remaining

remaining: number

The number of tokens that remains

Defined in

lib/utils/SequentialBucket.ts:35open in new window


reset

reset: number

Timestamp of next reset

Defined in

lib/utils/SequentialBucket.ts:40open in new window

Methods

check

Private check(force?): void

Parameters

NameTypeDefault value
forcebooleanfalse

Returns

void

Defined in

lib/utils/SequentialBucket.ts:50open in new window


queue

queue(func, priority?): void

Queue an item to be executed in the Bucket

Parameters

NameTypeDefault valueDescription
func(cb: () => void) => voidundefinedThe function to queue
prioritybooleanfalseIf true, the item will be added to the front of the queue

Returns

void

Defined in

lib/utils/SequentialBucket.ts:101open in new window

Last Updated:
Contributors: Reinhardt