RetryPolicyConfig
Configuration class for defining the behavior of a RetryPolicy.
This class holds the parameters that control how and when retries are performed. It is typically used within a DSL to configure a retry mechanism.
Properties
The strategy to determine the delay between retry attempts. Defaults to ExponentialBackoff.
The maximum number of times an operation will be attempted. Includes the initial attempt. Defaults to 3.
If set, each attempt (including the first) is limited to this duration. When exceeded, the attempt is cancelled and may be retried according to shouldRetry (e.g. kotlinx.coroutines.TimeoutCancellationException is typically retryable). Use this when you want a timeout per attempt rather than a single global timeout from a TimeoutPolicy. Defaults to null (no per-attempt timeout).
A predicate to decide if a retry should be performed based on the Throwable that was caught. Defaults to a lambda that always returns true, meaning any exception will trigger a retry.
Optional predicate run after block completes without throwing. Return true to treat the outcome as needing another attempt (same maxAttempts budget as exception retries). Return false to accept the value. Default is null (only shouldRetry applies). When true, onRetry is invoked with RetryableResultException (see RetryableResultException.lastValue). If maxAttempts is exhausted while the predicate keeps returning true, the last returned value is returned (unlike exception exhaustion, which rethrows the last Throwable).