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>
AThrottlingStrategy
that provides a throttling strategy based on QPS. The throttling works by examining the number of requests from theThrottlingService
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
All Methods Instance Methods Concrete Methods 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 Detail
-
RateLimitingThrottlingStrategy
public RateLimitingThrottlingStrategy(double requestPerSecond, @Nullable String name)
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 Detail
-
accept
public CompletionStage<Boolean> accept(ServiceRequestContext ctx, T request)
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>
-
-