RetryEngine

Pure retry delay calculator. Stateless — no side effects.

Used by platform workers (Android CoroutineWorker, iOS task handler) to determine how long to wait before the next attempt.

Delay formula by policy:

Example:

val policy = RetryPolicy.Exponential(initialDelayMillis = 5_000)
RetryEngine.nextDelay(0, policy) // 5_000ms
RetryEngine.nextDelay(1, policy) // 10_000ms
RetryEngine.nextDelay(2, policy) // 20_000ms

Functions

Link copied to clipboard
fun nextDelay(retryCount: Int, policy: RetryPolicy): Long

Returns the delay in milliseconds before the next retry attempt.

Link copied to clipboard
fun shouldRetry(retryCount: Int, policy: RetryPolicy): Boolean

Returns true if the task should be retried given the policy and current attempt count.