RFC: Add a Retry Policy to allow the client to dynamically retry requests #1875
tooboredtocode
started this conversation in
Development & RFCs
Replies: 1 comment
-
(Crosspost from the development Discord channel.) There needs to be some sort of implementation plan. The request internals cannot support this without a partial rewrite, and as the request almost perfectly mirrors Tower's retry policy, it might make sense to not implement it at all but refactor the http crate to use and expose a Tower interface so that users may themselves add retry support. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Add a Retry Policy to allow the client to dynamically retry requests
Currently the client does not retry failed requests. However the client will, even while strictly following ratelimits, encounter occasional 429 responses.
To combat this the client will have to retry some failed requests. This could be implemented rather simply. However given that other errors might occasionally happen in some environments, implementing a dynamic policy that can be easily modified by a user will be a smarter choice.
Implementation
One way to achieve this would be to implement the following traits alongside their default implementation
And a corresponding default implementation
And a potential Reqest Data Implementation
The trait splits the code into two parts:
The Retry Policy can be used to generate an Executioner for each request collection (a request and its potential retries)
The Executioner can then be used to decide whether to retry or not and how long to wait until the next attempt based on the Request data
Separating those two allows someone implementing a custom implementation to differentiate errors happening in different requests, for example to track the count of different errors.
Alternative
Alternatively you could just retry requests hitting a ratelimit.
However doing so would be missing out on a lot of potential customisation for users.
Beta Was this translation helpful? Give feedback.
All reactions