Class RateLimitingThrottlingStrategy<T extends Request>
java.lang.Object
com.linecorp.armeria.server.throttling.ThrottlingStrategy<T>
com.linecorp.armeria.server.throttling.RateLimitingThrottlingStrategy<T>
public final class RateLimitingThrottlingStrategy<T extends Request> extends ThrottlingStrategy<T>
A
ThrottlingStrategy
that provides a throttling strategy based on QPS.
The throttling works by examining the number of requests from the beginning, and
throttling if the QPS is found exceed the specified tolerable maximum.-
Constructor Summary
Constructors Constructor Description RateLimitingThrottlingStrategy(double requestPerSecond)
Creates a new strategy.RateLimitingThrottlingStrategy(double requestPerSecond, String name)
Creates a new strategy with specified name. -
Method Summary
Modifier and Type Method Description CompletionStage<Boolean>
accept(ServiceRequestContext ctx, T request)
Returns whether a given request should be treated as failed before it is handled actually.
-
Constructor Details
-
RateLimitingThrottlingStrategy
Creates a new strategy with specified name.- Parameters:
requestPerSecond
- the number of requests per one second thisThrottlingStrategy
accepts.
-
RateLimitingThrottlingStrategy
public RateLimitingThrottlingStrategy(double requestPerSecond)Creates a new strategy.- Parameters:
requestPerSecond
- the number of requests per one second thisThrottlingStrategy
accepts.
-
-
Method Details
-
accept
Description copied from class:ThrottlingStrategy
Returns whether a given request should be treated as failed before it is handled actually.- Specified by:
accept
in classThrottlingStrategy<T extends Request>
-