- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
          Implement retry::always for a retry policy that applies to all domains
          #2848
        
          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
base: master
Are you sure you want to change the base?
Conversation
| 
           Thanks for the PR! This is an addition I'm quite hesitant about. The idea of "always" is a little hard to describe, because it's not really always. If it were, that would mean that every response is retried (even if "successful"), and you'd loop forever. In contrast, it's much easier to say what "never" means. When I was originally working on reqwest's retry module, my goals were to ease adding HTTP retries safely. It was already possible to do retries without reqwest's help, but when I would look at where people had done so, they often forget certain protections. So, one could do retries externally just in a loop. I'd want to open it up so advanced users can grab pieces from tower-http and hopefully still be safe but do more of what they need. And in  So, after saying all that, I think a possible next step would be a slightly more flexible way of defining scopes, with a healthy dose of "please be careful in here".  | 
    
| 
           I may misunderstand but from my understanding using  I would be curious to hear more about how you see a solution here working as I would be potentially be interested in contributing if I can get a better understanding! I do fully understand that this may require more thought on your end so all good if you can't outline it exactly! I think one clear solution would be exposing more of the retry traits ( I suspect this probably isn't the place for discussion on this but for my specific usecase I think defining the retry policy on the request would be a lot more flexible than on the client. This is leading me to believe maybe I should do a userspace retry implementation but i'm also aiming to reduce code we have to maintain and as discussed above retry code can be easy to get wrong. Previously we defined a new  Thanks for your time! I really appreciate the open source work you do!  | 
    
          
 Yes, that is a correct interpretation too. What I worry about is what does this mean to a user when they read it: Client::builder()
    .retries(reqwest::retry::always())
    .etc()When contrast with  (It's possible that the API design could have been adjusted slightly to include a couple generics such that if you said   | 
    
This is useful because in my case I want to have a global client for sharing the connection pool but I don't know the domains ahead of time for the retry policy as our application allows dynamic URLs. I know that I want all requests on this specific
reqwest::Clientto use the retry policy.This functionality could theoretically be implemented in userspace in the future but currently the
Scopetrait is sealed making that impossible so this would need to exist inreqwestfrom my current understanding.This is an opposite of the existing
reqwest::nevermethod.