Package org.comroid.restless.server
Interface Ratelimiter
-
- All Superinterfaces:
java.util.function.BiFunction<RatelimitedEndpoint,REST.Request,java.util.concurrent.CompletableFuture<REST.Request>>
public interface Ratelimiter extends java.util.function.BiFunction<RatelimitedEndpoint,REST.Request,java.util.concurrent.CompletableFuture<REST.Request>>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classRatelimiter.Support
-
Field Summary
Fields Modifier and Type Field Description static RatelimiterINSTANTstatic com.google.common.flogger.FluentLoggerlogger
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<REST.Request>apply(RatelimitedEndpoint restEndpoint, REST.Request request)static intcalculateOffset(int rps, int size)static RatelimiterofPool(java.util.concurrent.ScheduledExecutorService executor, RatelimitedEndpoint... endpoints)
-
-
-
Field Detail
-
logger
static final com.google.common.flogger.FluentLogger logger
-
INSTANT
static final Ratelimiter INSTANT
-
-
Method Detail
-
ofPool
static Ratelimiter ofPool(java.util.concurrent.ScheduledExecutorService executor, RatelimitedEndpoint... endpoints)
-
calculateOffset
static int calculateOffset(int rps, int size)
-
apply
java.util.concurrent.CompletableFuture<REST.Request> apply(RatelimitedEndpoint restEndpoint, REST.Request request)
Applies the provided request with the given endpoint to this ratelimiter and returns a CompletionStage that completes with the given request as soon as this ratelimiter allows its execution.- Specified by:
applyin interfacejava.util.function.BiFunction<RatelimitedEndpoint,REST.Request,java.util.concurrent.CompletableFuture<REST.Request>>- Parameters:
restEndpoint- The endpoint that is gonna be accessedrequest- The request that is yet to be executed- Returns:
- A CompletableFuture that completes as soon as the ratelimiter allows execution of the request.
-
-