Skip to content

RequestRetrier for URLSession implementation #41

@farllight

Description

@farllight

ApexyURLSession is very lightweight and useful. I want use Apexy without Alamofire in my case.

But, ApexyAlamofire has injected RequestInterceptor with method:

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

Using this method very useful. What do you all think about an idea add a protocol RequestRetrier? It has enum RetryResult (copied from Alamofire):

/// Outcome of determination whether retry is necessary.
public enum RetryResult {
    /// Retry should be attempted immediately.
    case retry
    /// Retry should be attempted after the associated `TimeInterval`.
    case retryWithDelay(TimeInterval)
    /// Do not retry.
    case doNotRetry
    /// Do not retry due to the associated `Error`.
    case doNotRetryWithError(Error)
}
  1. Inject him in URLSessionClient init with default implementation
  2. When dataTask/uploadTask error catched, call recursively request/upload methods, when RetryResult equal retry/retryWithDelay
  3. In cases doNotRetry/doNotRetryWithError throw error

I want implement this behaviour, if active community members thinks that my proposal will be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions