LeakyBucket
@discordeno/utils • Docs
Documentation / @discordeno/utils / LeakyBucket
Class: LeakyBucket
Implements
Constructors
new LeakyBucket()
new LeakyBucket(
options
?):LeakyBucket
Parameters
• options?: LeakyBucketOptions
Returns
Defined in
packages/utils/src/bucket.ts:22
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
Defined in
packages/utils/src/bucket.ts:20
max
max:
number
Max requests allowed at once.
Default
1
Implementation of
Defined in
packages/utils/src/bucket.ts:5
processing
processing:
boolean
=false
Whether or not the queue is already processing.
Defined in
packages/utils/src/bucket.ts:14
queue
queue: (
value
) =>void
[] =[]
The queue of requests to acquire an available request. Mapped by <shardId, resolve()>
Defined in
packages/utils/src/bucket.ts:12
refillAmount
refillAmount:
number
Amount of requests to refill at each interval.
Default
1
Implementation of
LeakyBucketOptions
.refillAmount
Defined in
packages/utils/src/bucket.ts:7
refillInterval
refillInterval:
number
Interval in milliseconds between refills.
Default
5000
Implementation of
LeakyBucketOptions
.refillInterval
Defined in
packages/utils/src/bucket.ts:6
refillsAt?
optional
refillsAt:number
The timestamp in milliseconds when the next refill is scheduled.
Defined in
packages/utils/src/bucket.ts:18
timeoutId?
optional
timeoutId:Timeout
The timeout id for the timer to reduce the used amount by the refill amount.
Defined in
packages/utils/src/bucket.ts:16
used
used:
number
=0
The amount of requests that have been used up already.
Defined in
packages/utils/src/bucket.ts:10
Accessors
remaining
Get Signature
get remaining():
number
The amount of requests that still remain.
Returns
number
Defined in
packages/utils/src/bucket.ts:30
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/src/bucket.ts:106
processQueue()
processQueue():
Promise
<void
>
Begin processing the queue.
Returns
Promise
<void
>
Defined in
packages/utils/src/bucket.ts:54
refillBucket()
refillBucket():
void
Refills the bucket as needed.
Returns
void