Retry Policy
data class RetryPolicy(val maxAttempts: Int = 3, val initialDelay: Duration = 100.milliseconds, val maxDelay: Duration = 10.seconds, val multiplier: Double = 2.0, val jitter: Double = 0.1, val retryOn: (Throwable) -> Boolean = { true })
Retry policy for saga step execution with exponential backoff.
Defines how failed saga steps should be retried, including:
Maximum retry attempts
Exponential backoff with configurable parameters
Jitter to prevent thundering herd
Conditional retry based on exception type
Usage Example
val retryPolicy = RetryPolicy(
maxAttempts = 3,
initialDelay = 100.milliseconds,
maxDelay = 5.seconds,
multiplier = 2.0,
jitter = 0.1
)
sagaExecutor<Ctx, Result> {
step("flaky-operation") { context ->
externalService.call(context)
}
.withRetry(retryPolicy)
}Content copied to clipboard