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 Details

    • builder

      public static <T extends com.linecorp.armeria.common.Request> TokenBucketThrottlingStrategyBuilder<T> builder(TokenBucket tokenBucket)
      Returns a newly created TokenBucketThrottlingStrategyBuilder.
    • reconfigure

      public CompletableFuture<Void> reconfigure(TokenBucket tokenBucket)
      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

      public CompletionStage<Boolean> accept(com.linecorp.armeria.server.ServiceRequestContext ctx, T request)
      Registers a request with the bucket.
      Specified by:
      accept in class com.linecorp.armeria.server.throttling.ThrottlingStrategy<T extends com.linecorp.armeria.common.Request>