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.
Encapsulates the logic of determining a delay when some criteria is met.
- Author:
- Randall Hauch
-
Method Summary
Modifier and TypeMethodDescriptionstatic DelayStrategy
Create a delay strategy that applies a constant delay as long as the criteria is met.static DelayStrategy
exponential
(Duration initialDelay, Duration maxDelay) Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met.static DelayStrategy
exponential
(Duration initialDelay, Duration maxDelay, double backOffMultiplier) Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met.static DelayStrategy
Create a delay strategy that applies an linearly-increasing delay as long as the criteria is met.static DelayStrategy
none()
Create a delay strategy that never delays.boolean
sleepWhen
(boolean criteria) Attempt to sleep when the specified criteria is met.default boolean
sleepWhen
(BooleanSupplier criteria) Attempt to sleep when the specified criteria is met.
-
Method Details
-
sleepWhen
Attempt to sleep when the specified criteria is met.- Parameters:
criteria
-true
if this method should sleep, orfalse
if there is no need to sleep- Returns:
true
if this invocation caused the thread to sleep, orfalse
if this method did not sleep
-
sleepWhen
boolean sleepWhen(boolean criteria) Attempt to sleep when the specified criteria is met.- Parameters:
criteria
-true
if this method should sleep, orfalse
if there is no need to sleep- Returns:
true
if this invocation caused the thread to sleep, orfalse
if this method did not sleep
-
none
Create a delay strategy that never delays.- Returns:
- the strategy; never null
-
constant
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:
delay
- the initial delay; must be positive- Returns:
- the strategy; never null
-
linear
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:
delay
- the initial delay; must be positive- Returns:
- the strategy; never null
-
exponential
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:
initialDelay
- the initial delay; must be positivemaxDelay
- the maximum delay; must be greater than the initial delay- Returns:
- the strategy; never null
-
exponential
static DelayStrategy exponential(Duration initialDelay, Duration maxDelay, 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:
initialDelay
- the initial delay; must be positivemaxDelay
- the maximum delay; must be greater than the initial delaybackOffMultiplier
- the factor by which the delay increases each pass- Returns:
- the strategy
-