Module io.github.bucket4j.core
Class DelayOptimization
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.optimization.delay.DelayOptimization
-
- All Implemented Interfaces:
Optimization
public class DelayOptimization extends Object implements Optimization
Optimization that can serve requests locally without synchronization with external storage until thresholds are not violated. This optimization is based on top ofBatchingOptimization, so multiple parallel request to same bucket are grouped.Usage of this optimization can lead to temporal overconsumption because the synchronization with external storage is performed periodically when thresholds are violated.
- See Also:
DelayParameters
-
-
Field Summary
-
Fields inherited from interface io.github.bucket4j.distributed.proxy.optimization.Optimization
NONE_OPTIMIZED
-
-
Constructor Summary
Constructors Constructor Description DelayOptimization(DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncCommandExecutorapply(AsyncCommandExecutor originalExecutor)Decorates command executor in order to apply optimization strategy.CommandExecutorapply(CommandExecutor originalExecutor)Decorates command executor in order to apply optimization strategy.OptimizationwithListener(OptimizationListener listener)Specifies the listener for optimization events
-
-
-
Constructor Detail
-
DelayOptimization
public DelayOptimization(DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter)
-
-
Method Detail
-
withListener
public Optimization withListener(OptimizationListener listener)
Description copied from interface:OptimizationSpecifies the listener for optimization events- Specified by:
withListenerin interfaceOptimization- Parameters:
listener- the listener for optimization events- Returns:
- the new instance of
Optimizationwith configured listener
-
apply
public CommandExecutor apply(CommandExecutor originalExecutor)
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-
apply
public AsyncCommandExecutor apply(AsyncCommandExecutor originalExecutor)
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-
-