Class TokenBucketThrottlingStrategy<T extends 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 Request>
extends 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 TypeMethodDescriptionaccept
(ServiceRequestContext ctx, T request) Registers a request with the bucket.static <T extends 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 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
CompletableFuture
to handle asynchronous result
-
accept
Registers a request with the bucket.- Specified by:
accept
in classThrottlingStrategy<T extends Request>
-