Package discord4j.rest.request
Interface GlobalRateLimiter
-
- All Known Implementing Classes:
BucketGlobalRateLimiter
public interface GlobalRateLimiterUsed to prevent requests from being sent while the bot is globally rate limited.Provides resources that can be acquired through the use of
withLimiter(Publisher), and held until the supplied stage completes or terminates with an error. If the limiter resources are exhausted, it will limit all other attempts, waiting until a resource becomes available.This rate limiter can have their delay directly modified through
rateLimitFor(Duration), determining the duration a resource holder must wait before processing starts.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static GlobalRateLimitercreate()Create a default limiter based offBucketGlobalRateLimiterthat can be shared across multipleRestClientfor coordinated global rate limit actions.Mono<Duration>getRemaining()Returns theDurationremaining until the current global rate limit is completed.Mono<Void>rateLimitFor(Duration duration)Sets a new rate limit that will be applied to every operation performed usingwithLimiter(Publisher).<T> Flux<T>withLimiter(Publisher<T> stage)Provides a scope to perform reactive operations under this global rate limiter.
-
-
-
Method Detail
-
create
static GlobalRateLimiter create()
Create a default limiter based offBucketGlobalRateLimiterthat can be shared across multipleRestClientfor coordinated global rate limit actions.- Returns:
- a default
GlobalRateLimiter
-
rateLimitFor
Mono<Void> rateLimitFor(Duration duration)
Sets a new rate limit that will be applied to every operation performed usingwithLimiter(Publisher).- Parameters:
duration- theDurationevery new operation should wait before being used
-
getRemaining
Mono<Duration> getRemaining()
Returns theDurationremaining until the current global rate limit is completed. Can be negative or zero if there is no currently active global rate limit.- Returns:
- a positive
Durationindicating the remaining time a global rate limit is being applied. Zero or negative if no global rate limit is currently active.
-
-