Structure
RetryPolicy
Defines retry behavior with exponential backoff for transient failures.
struct RetryPolicyOverview
Use RetryPolicy to wrap any throwing async operation with automatic retry logic. Each successive attempt waits longer before retrying (exponential backoff).
Usage
let policy = RetryPolicy(maxAttempts: 3, initialDelay: .seconds(1), multiplier: 2.0)
let result = try await policy.execute {
try await uploadChunk(data: data)
}Topics
Initializers
init(maxAttempts: Int, initialDelay: Duration, multiplier: Double)Creates a
RetryPolicy.
Instance Properties
let initialDelay: DurationDelay before the second attempt. Subsequent delays are multiplied by
multiplier.let maxAttempts: IntMaximum number of attempts (including the first try).
let multiplier: DoubleFactor by which the delay grows on each retry.
Instance Methods
func execute<T>(() async throws -> T) async throws -> TExecute an async operation with automatic retry on failure.
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype