Functions

Link copied to clipboard
private fun applyJitter(baseDelay: Duration, randomizationFactor: Double): Duration

Applies jitter to a given duration based on a randomization factor.

Link copied to clipboard
fun constant(delay: Duration, randomizationFactor: Double = 0.0): DelayStrategy

A delay strategy that uses a constant backoff algorithm to calculate the next delay duration. The algorithm is based on the formula:

Link copied to clipboard

A delay strategy that uses a custom delay provider, which extends the behaviour of a CtxDelayStrategy, by allowing external control of the delay execution with optional state.

A delay strategy that uses a custom delay provider, which extends the behaviour of a DelayStrategy, by allowing external control of the delay execution with optional state.

Link copied to clipboard
fun exponential(initialDelay: Duration, maxDelay: Duration = Duration.INFINITE, multiplier: Double = 2.0, randomizationFactor: Double = 0.0): DelayStrategy

A delay strategy that uses the exponential backoff algorithm to calculate the next delay duration. The algorithm is based on the formula:

Link copied to clipboard
fun linear(initialDelay: Duration, multiplier: Double = 1.0, maxDelay: Duration = Duration.INFINITE, randomizationFactor: Double = 0.0): DelayStrategy

A delay strategy that uses a linear backoff algorithm to calculate the next delay duration. The algorithm is based on the formula:

Link copied to clipboard

A delay strategy that has no delay between attempts. Attempts are immediate and do not use any custom DelayProvider.

Link copied to clipboard

Converts a DelayStrategy into a CtxDelayStrategy using Unit as the context. This is useful when no additional context is needed, allowing the caller to avoid providing a Unit context. It maintains compatibility with the more general CtxDelayStrategy type.

Link copied to clipboard
private fun validateConstantDelayParams(delay: Duration, randomizationFactor: Double)

Validates the constant delay parameters.

Link copied to clipboard
private fun validateExponentialDelayParams(initialDelay: Duration, multiplier: Double, maxDelay: Duration, randomizationFactor: Double)

Validates the exponential delay parameters.

Link copied to clipboard
private fun validateLinearDelayParams(initialDelay: Duration, multiplier: Double, maxDelay: Duration, randomizationFactor: Double)

Validates the linear delay parameters.