Module io.github.bucket4j.core
Package io.github.bucket4j.distributed
Interface AsyncOptimizationController
- All Known Implementing Classes:
AsyncBucketProxyAdapter,DefaultAsyncBucketProxy
public interface AsyncOptimizationController
The optimization controller for
AsyncBucketProxy.
This interface is actual only if an optimization was applied during bucket construction via RemoteAsyncBucketBuilder.withOptimization(Optimization)
otherwise all methods of controller will do nothing.
-
Method Summary
Modifier and TypeMethodDescriptionsyncByCondition(long unsynchronizedTokens, Duration timeSinceLastSync) Initiates immediate synchronization of local copy of bucket with remote storage in case of both conditions bellow aretrue: Accumulated amount of locally consumed tokens without external synchronization is greater than or equal tounsynchronizedTokensTime passed since last synchronization with external storage is greater than or equal totimeSinceLastSyncdefault CompletableFuture<Void>Initiates immediate synchronization of local copy of bucket with remote storage
-
Method Details
-
syncImmediately
Initiates immediate synchronization of local copy of bucket with remote storage- Returns:
- future that will be completed when local copy of bucket will be synchronized with remote storage, or immediately completed future in case of this synchronization is not required.
-
syncByCondition
Initiates immediate synchronization of local copy of bucket with remote storage in case of both conditions bellow aretrue:- Accumulated amount of locally consumed tokens without external synchronization is greater than or equal to
unsynchronizedTokens - Time passed since last synchronization with external storage is greater than or equal to
timeSinceLastSync
- Parameters:
unsynchronizedTokens- criterion for accumulated amount of unsynchronized tokenstimeSinceLastSync- criterion for time passed since last synchronization- Returns:
- future that will be completed when local copy of bucket will be synchronized with remote storage, or immediately completed future in case of this synchronization is not required.
- Accumulated amount of locally consumed tokens without external synchronization is greater than or equal to
-