Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestRetrier for URLSession implementation #41

Open
farllight opened this issue Oct 22, 2022 · 4 comments
Open

RequestRetrier for URLSession implementation #41

farllight opened this issue Oct 22, 2022 · 4 comments

Comments

@farllight
Copy link

farllight commented Oct 22, 2022

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.

@farllight
Copy link
Author

@laqiguy

1 similar comment
@farllight
Copy link
Author

@laqiguy

@vani2
Copy link
Collaborator

vani2 commented Feb 9, 2023

@laqiguy 😀

@laqiguy
Copy link
Contributor

laqiguy commented Mar 1, 2023

Good proposal

But it only make sense if it matches with Alamofire Retrier. You need to add also implementation in Alamofire part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants