Back to Alamofire

RequestRetrier

docs/Protocols/RequestRetrier.html

5.12.01.8 KB
Original Source

RequestRetrier

public protocol RequestRetrier : Sendable

A type that determines whether a request should be retried after being executed by the specified session manager and encountering an error.

`

                retry(_:for:dueTo:completion:)
                `

Determines whether the Request should be retried by calling the completion closure.

This operation is fully asynchronous. Any amount of time can be taken to determine whether the request needs to be retried. The one requirement is that the completion closure is called to ensure the request is properly cleaned up after.

Declaration

Swift

func retry(_ request: Request, for session: Session, dueTo error: any Error, completion: @escaping @Sendable (RetryResult) -> Void)

Parameters

| request |

Request that failed due to the provided Error.

| | session |

Session that produced the Request.

| | error |

Error encountered while executing the Request.

| | completion |

Completion closure to be executed when a retry decision has been determined.

|

Available where Self == Retrier

`

                retrier(using:)
                ` Extension method 

Creates a Retrier using the provided RetryHandler closure.

Declaration

Swift

@preconcurrency
public static func retrier(using closure: @escaping RetryHandler) -> Retrier

Parameters

| closure |

RetryHandler to use to retry the request.

|

Return Value

The Retrier.