Package io.debezium.util
Interface DelayStrategy
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface DelayStrategy
Encapsulates the logic of determining a delay when some criteria is met.- Author:
- Randall Hauch
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static DelayStrategyconstant(long delayInMilliseconds)Create a delay strategy that applies a constant delay as long as the criteria is met.static DelayStrategyexponential(long initialDelayInMilliseconds, long maxDelayInMilliseconds)Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met.static DelayStrategyexponential(long initialDelayInMilliseconds, long maxDelayInMilliseconds, double backOffMultiplier)Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met.static DelayStrategylinear(long delayInMilliseconds)Create a delay strategy that applies an linearly-increasing delay as long as the criteria is met.static DelayStrategynone()Create a delay strategy that never delays.booleansleepWhen(boolean criteria)Attempt to sleep when the specified criteria is met.default booleansleepWhen(BooleanSupplier criteria)Attempt to sleep when the specified criteria is met.
-
-
-
Method Detail
-
sleepWhen
default boolean sleepWhen(BooleanSupplier criteria)
Attempt to sleep when the specified criteria is met.- Parameters:
criteria-trueif this method should sleep, orfalseif there is no need to sleep- Returns:
trueif this invocation caused the thread to sleep, orfalseif this method did not sleep
-
sleepWhen
boolean sleepWhen(boolean criteria)
Attempt to sleep when the specified criteria is met.- Parameters:
criteria-trueif this method should sleep, orfalseif there is no need to sleep- Returns:
trueif this invocation caused the thread to sleep, orfalseif this method did not sleep
-
none
static DelayStrategy none()
Create a delay strategy that never delays.- Returns:
- the strategy; never null
-
constant
static DelayStrategy constant(long delayInMilliseconds)
Create a delay strategy that applies a constant delay as long as the criteria is met. As soon as the criteria is not met, the delay resets to zero.- Parameters:
delayInMilliseconds- the initial delay; must be positive- Returns:
- the strategy; never null
-
linear
static DelayStrategy linear(long delayInMilliseconds)
Create a delay strategy that applies an linearly-increasing delay as long as the criteria is met. As soon as the criteria is not met, the delay resets to zero.- Parameters:
delayInMilliseconds- the initial delay; must be positive- Returns:
- the strategy; never null
-
exponential
static DelayStrategy exponential(long initialDelayInMilliseconds, long maxDelayInMilliseconds)
Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met. As soon as the criteria is not met, the delay resets to zero.- Parameters:
initialDelayInMilliseconds- the initial delay; must be positivemaxDelayInMilliseconds- the maximum delay; must be greater than the initial delay- Returns:
- the strategy; never null
-
exponential
static DelayStrategy exponential(long initialDelayInMilliseconds, long maxDelayInMilliseconds, double backOffMultiplier)
Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met. As soon as the criteria is not met, the delay resets to zero.- Parameters:
initialDelayInMilliseconds- the initial delay; must be positivemaxDelayInMilliseconds- the maximum delay; must be greater than the initial delaybackOffMultiplier- the factor by which the delay increases each pass- Returns:
- the strategy
-
-