hoshii / Exports / SequentialBucket
SequentialBucket
A sequential bucket for ratelimits
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new SequentialBucket(limit
, latencyRef
)
Parameters
Name | Type |
---|---|
limit | number |
latencyRef | LatencyRef |
Defined in
lib/utils/SequentialBucket.ts:42
Properties
_queue
• Private
_queue: (cd
: () => void
) => void
[]
The queue of functions to be executed
Defined in
lib/utils/SequentialBucket.ts:10
last
• last: number
Timestamp of last token consumption
Defined in
lib/utils/SequentialBucket.ts:15
latencyRef
• latencyRef: LatencyRef
A reference to the latency of the client
Defined in
lib/utils/SequentialBucket.ts:20
limit
• limit: number
The maximum number of tokens per interval
Defined in
lib/utils/SequentialBucket.ts:25
processing
• processing: boolean
| Timeout
Whether the queue is currently being processed
Defined in
lib/utils/SequentialBucket.ts:30
remaining
• remaining: number
The number of tokens that remains
Defined in
lib/utils/SequentialBucket.ts:35
reset
• reset: number
Timestamp of next reset
Defined in
lib/utils/SequentialBucket.ts:40
Methods
check
▸ Private
check(force?
): void
Parameters
Name | Type | Default value |
---|---|---|
force | boolean | false |
Returns
void
Defined in
lib/utils/SequentialBucket.ts:50
queue
▸ queue(func
, priority?
): void
Queue an item to be executed in the Bucket
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | (cb : () => void ) => void | undefined | The function to queue |
priority | boolean | false | If true, the item will be added to the front of the queue |
Returns
void