RetryPolicy

class RetryPolicy(val maxAttempts: Int = DEFAULT_MAX_ATTEMPTS, val initialBackoff: Duration = DEFAULT_INITIAL_BACKOFF, val maxBackoff: Duration = DEFAULT_MAX_BACKOFF, val jitterFactor: Double = DEFAULT_JITTER_FACTOR, val shouldRetry: (Exception) -> Boolean = { true })

Policy for retryWithBackoff.

Not a data class: shouldRetry is excluded from equals/hashCode so two policies with the same numeric settings compare equal regardless of predicate identity.

Parameters

maxAttempts

Total tries including the first (must be ≥ 1).

initialBackoff

Delay before the second attempt.

maxBackoff

Cap for exponential backoff growth.

jitterFactor

Fraction of the current backoff used as ± jitter (0 disables jitter).

shouldRetry

Return false to stop retrying and rethrow immediately (after the failed attempt). CancellationException is always rethrown and never retried.

Constructors

Link copied to clipboard
constructor(maxAttempts: Int = DEFAULT_MAX_ATTEMPTS, initialBackoff: Duration = DEFAULT_INITIAL_BACKOFF, maxBackoff: Duration = DEFAULT_MAX_BACKOFF, jitterFactor: Double = DEFAULT_JITTER_FACTOR, shouldRetry: (Exception) -> Boolean = { true })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun copy(maxAttempts: Int = this.maxAttempts, initialBackoff: Duration = this.initialBackoff, maxBackoff: Duration = this.maxBackoff, jitterFactor: Double = this.jitterFactor, shouldRetry: (Exception) -> Boolean = this.shouldRetry): RetryPolicy
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String