public interface AsyncBucketProxy
BucketProxy
.Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
addTokens(long tokensToAdd)
Asynchronous version of
Bucket.addTokens(long) , follows the same semantic. |
SchedulingBucket |
asScheduler()
Returns asynchronous view of this bucket that allows to use bucket as async scheduler.
|
AsyncVerboseBucket |
asVerbose()
Returns the verbose view of this bucket.
|
CompletableFuture<Long> |
consumeIgnoringRateLimits(long tokens)
Asynchronous version of
Bucket.consumeIgnoringRateLimits(long) , follows the same semantic. |
CompletableFuture<EstimationProbe> |
estimateAbilityToConsume(long numTokens)
Asynchronous version of
Bucket.estimateAbilityToConsume(long) , follows the same semantic. |
CompletableFuture<Void> |
forceAddTokens(long tokensToAdd)
Asynchronous version of
Bucket.forceAddTokens(long) , follows the same semantic. |
CompletableFuture<Long> |
getAvailableTokens()
Returns amount of available tokens in this bucket.
|
AsyncOptimizationController |
getOptimizationController()
Returns optimization controller for this proxy.
|
CompletableFuture<Void> |
replaceConfiguration(BucketConfiguration newConfiguration,
TokensInheritanceStrategy tokensInheritanceStrategy)
Has the same semantic with
Bucket.replaceConfiguration(BucketConfiguration, TokensInheritanceStrategy) |
AsyncBucketProxy |
toListenable(BucketListener listener)
Returns new copy of this bucket instance decorated by
listener . |
CompletableFuture<Boolean> |
tryConsume(long numTokens)
Asynchronous version of
Bucket.tryConsume(long) , follows the same semantic. |
CompletableFuture<ConsumptionProbe> |
tryConsumeAndReturnRemaining(long numTokens)
Asynchronous version of
Bucket.tryConsumeAndReturnRemaining(long) , follows the same semantic. |
CompletableFuture<Long> |
tryConsumeAsMuchAsPossible()
Asynchronous version of
Bucket.tryConsumeAsMuchAsPossible() , follows the same semantic. |
CompletableFuture<Long> |
tryConsumeAsMuchAsPossible(long limit)
Asynchronous version of
Bucket.tryConsumeAsMuchAsPossible(long) , follows the same semantic. |
SchedulingBucket asScheduler()
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)
AsyncBucketProxy toListenable(BucketListener listener)
listener
.
The created bucket will share same tokens with source bucket and vice versa.
See javadocs for BucketListener
in order to understand semantic of listener.listener
- the listener of bucket events.listener
CompletableFuture<Long> getAvailableTokens()
This method designed to be used only for monitoring and testing, you should never use this method for business cases, because available tokens can be changed by concurrent transactions for case of multithreaded/multi-process environment.
AsyncOptimizationController getOptimizationController()
This method is actual only if an optimization was applied during bucket construction via RemoteAsyncBucketBuilder.withOptimization(Optimization)
otherwise returned controller will do nothing.
Copyright © 2021. All rights reserved.