public interface AsyncBucket
Extension behind the bucket provides asynchronous mode.
A special notes about in-memory buckets:: this interface is useless for in-memory buckets because in-memory bucket does not communicate with external back-ends, as result any thread is never blocked by IO operations.
AsyncVerboseBucket asVerbose()
CompletableFuture<Boolean> tryConsume(long numTokens)
Bucket.tryConsume(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.tryConsume(long)numTokens - The number of tokens to consume from the bucket, must be a positive number.true if the numTokens were consumed and completed by false otherwise.Bucket.tryConsume(long)CompletableFuture<Long> consumeIgnoringRateLimits(long tokens)
Bucket.consumeIgnoringRateLimits(long), follows the same semantic.Bucket.consumeIgnoringRateLimits(long)CompletableFuture<ConsumptionProbe> tryConsumeAndReturnRemaining(long numTokens)
Bucket.tryConsumeAndReturnRemaining(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.tryConsumeAndReturnRemaining(long)numTokens - The number of tokens to consume from the bucket, must be a positive number.probe which describes both result of consumption and tokens remaining in the bucket after consumption.Bucket.tryConsumeAndReturnRemaining(long)CompletableFuture<EstimationProbe> estimateAbilityToConsume(long numTokens)
Bucket.estimateAbilityToConsume(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.estimateAbilityToConsume(long)numTokens - The number of tokens to consume from the bucket, must be a positive number.probe which describes the ability to consume specified amount of tokens.Bucket.estimateAbilityToConsume(long)CompletableFuture<Long> tryConsumeAsMuchAsPossible()
Bucket.tryConsumeAsMuchAsPossible(), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.tryConsumeAsMuchAsPossible()Bucket.tryConsumeAsMuchAsPossible()CompletableFuture<Long> tryConsumeAsMuchAsPossible(long limit)
Bucket.tryConsumeAsMuchAsPossible(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.tryConsumeAsMuchAsPossible(long)limit - maximum number of tokens to consume, should be positive.Bucket.tryConsumeAsMuchAsPossible(long)CompletableFuture<Void> addTokens(long tokensToAdd)
Bucket.addTokens(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.addTokens(long)tokensToAdd - number of tokens to addBucket.addTokens(long)CompletableFuture<Void> forceAddTokens(long tokensToAdd)
Bucket.forceAddTokens(long), follows the same semantic.
The algorithm for distribute buckets is following:
CompletableFuture.thenApplyAsync(Function, Executor).
The algorithm for local buckets is following:
Bucket.addTokens(long)tokensToAdd - number of tokens to addBucket.addTokens(long)CompletableFuture<Void> replaceConfiguration(BucketConfiguration newConfiguration, TokensInheritanceStrategy tokensInheritanceStrategy)
Bucket.replaceConfiguration(BucketConfiguration, TokensInheritanceStrategy)Copyright © 2021. All rights reserved.