Package com.mewna.catnip.rest.ratelimit
Class DefaultRateLimiter
java.lang.Object
com.mewna.catnip.rest.ratelimit.DefaultRateLimiter
- All Implemented Interfaces:
RateLimiter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
io.reactivex.rxjava3.core.Completable
requestExecution
(Routes.Route route) Requests execution for a specific route.void
updateDone
(Routes.Route route) void
updateGlobalRateLimit
(long resetTimestamp) void
updateLimit
(Routes.Route route, int limit) void
updateRemaining
(Routes.Route route, int remaining) void
updateReset
(Routes.Route route, long resetTimestamp)
-
Constructor Details
-
DefaultRateLimiter
public DefaultRateLimiter()
-
-
Method Details
-
catnip
- Specified by:
catnip
in interfaceRateLimiter
-
requestExecution
Description copied from interface:RateLimiter
Requests execution for a specific route. The route cannot be executed on until the bucket has requests available again, so the ratelimiter must handle this correctly.- Specified by:
requestExecution
in interfaceRateLimiter
- Parameters:
route
- The route to execute.- Returns:
- A
Completable
that completes when the route can execute again.
-
updateLimit
- Specified by:
updateLimit
in interfaceRateLimiter
-
updateRemaining
- Specified by:
updateRemaining
in interfaceRateLimiter
-
updateReset
- Specified by:
updateReset
in interfaceRateLimiter
-
updateDone
- Specified by:
updateDone
in interfaceRateLimiter
-
updateGlobalRateLimit
public void updateGlobalRateLimit(long resetTimestamp) - Specified by:
updateGlobalRateLimit
in interfaceRateLimiter
-