Class TokenBucketThrottlingStrategy<T extends com.linecorp.armeria.common.Request>
java.lang.Object
com.linecorp.armeria.server.throttling.ThrottlingStrategy<T>
com.linecorp.armeria.server.throttling.bucket4j.TokenBucketThrottlingStrategy<T>
@UnstableApi
public final class TokenBucketThrottlingStrategy<T extends com.linecorp.armeria.common.Request>
extends com.linecorp.armeria.server.throttling.ThrottlingStrategy<T>
A
ThrottlingStrategy that provides a throttling strategy based on Token-Bucket algorithm.
The throttling works by examining the number of requests from the beginning, and
throttling if the request rate exceed the configured bucket limits.-
Method Summary
Modifier and TypeMethodDescriptionRegisters a request with the bucket.static <T extends com.linecorp.armeria.common.Request>
TokenBucketThrottlingStrategyBuilder<T>builder(TokenBucket tokenBucket) Returns a newly createdTokenBucketThrottlingStrategyBuilder.reconfigure(TokenBucket tokenBucket) Resets the Token-Bucket configuration at runtime by providing a new set of limits.Methods inherited from class com.linecorp.armeria.server.throttling.ThrottlingStrategy
always, name, never, of, of, rateLimiting, rateLimiting
-
Method Details
-
builder
public static <T extends com.linecorp.armeria.common.Request> TokenBucketThrottlingStrategyBuilder<T> builder(TokenBucket tokenBucket) Returns a newly createdTokenBucketThrottlingStrategyBuilder. -
reconfigure
Resets the Token-Bucket configuration at runtime by providing a new set of limits. Empty set of limits will remove previously set limits. Reconfiguration will take place asynchronously.- Parameters:
tokenBucket- Token-Bucket configuration- Returns:
- A
CompletableFutureto handle asynchronous result
-
accept
public CompletionStage<Boolean> accept(com.linecorp.armeria.server.ServiceRequestContext ctx, T request) Registers a request with the bucket.- Specified by:
acceptin classcom.linecorp.armeria.server.throttling.ThrottlingStrategy<T extends com.linecorp.armeria.common.Request>
-