PriorityGlobalRestRateLimiter

An implementation of RestRateLimiter which handles the global rate limit (50/s), and in which low-priority requests are queued last to the delegate (such as application command updates).

While JDA already reads the global rate limit headers, it does not prevent doing 50+ requests on different buckets. For example, when updating commands on 50+ guilds, JDA would launch all requests in parallel, as each guild has its own bucket, resulting in a hefty rate limit.

When using this, guild commands will be updated as fast as possible, otherwise, it will be slowed down.

It is highly recommended using this (or your own implementation) with large bots.

Usage

You will need to configure the RestConfig on your DefaultShardManagerBuilder.

Example:

val restConfig = RestConfig()
.setRateLimiterFactory { rlConfig: RateLimitConfig ->
PriorityGlobalRestRateLimiter(SequentialRestRateLimiter(rlConfig))
}
setRestConfig(restConfig)

Constructors

Link copied to clipboard
constructor(delegate: RestRateLimiter)

Functions

Link copied to clipboard
open override fun cancelRequests(): Int
Link copied to clipboard
open override fun enqueue(task: RestRateLimiter.Work)
Link copied to clipboard
open override fun isStopped(): Boolean
Link copied to clipboard
open override fun stop(shutdown: Boolean, callback: Runnable)