public final class RateLimitingThrottlingStrategy<T extends Request> extends ThrottlingStrategy<T>
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 and Description |
|---|
RateLimitingThrottlingStrategy(double requestPerSecond)
Creates a new strategy.
|
RateLimitingThrottlingStrategy(double requestPerSecond,
String name)
Creates a new strategy with specified name.
|
| Modifier and Type | Method and Description |
|---|---|
CompletionStage<Boolean> |
accept(ServiceRequestContext ctx,
T request)
Returns whether a given request should be treated as failed before it is handled actually.
|
public RateLimitingThrottlingStrategy(double requestPerSecond,
String name)
requestPerSecond - the number of requests per one second this ThrottlingStrategy accepts.public RateLimitingThrottlingStrategy(double requestPerSecond)
requestPerSecond - the number of requests per one second this ThrottlingStrategy accepts.public CompletionStage<Boolean> accept(ServiceRequestContext ctx, T request)
ThrottlingStrategyaccept in class ThrottlingStrategy<T extends Request>Copyright © 2020 LeanCloud. All rights reserved.