-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Calculating sleep duration for WaitAndRetry, based on the execution result; eg 429 headers #177
Comments
@jmansar Thanks for bringing this really interesting idea across from our slack channel! Main question in my mind: whether exposing result directly to So: how else can we do this, that keeps the Polly architecture evolving in a coherent way? In this case I'm thinking we’d probably want to support this by expanding the role of the Making
Note there are other similar (in a very broad sense) issues like #38 . Also about exchanging data between execution and Policy-operation-influencing delegates. My suggestion-in-the-meantime for your use case is similar to at bottom of #38. Close over some common variable in the |
+1 Exact same use case for me. Passing in the exception as a parameter to the sleepDurationProvider would also work if that makes it simpler. |
@johnmcase @jmansar This is added to the roadmap, in the generalized/extensible way I propose we should take this forward. |
+1 |
@jmansar @johnmcase @tcsatheesh Planning to deliver this feature in the next release 😄 . (already coded) Per my previous comment, Polly is being expanded so that every delegate referenced by a policy (executed delegates; and policy control delegates such as For Code example:
EDIT: I plan to blog a detailed code example when released. EDIT: The release may accompany the |
@jmansar This feature has been released in the v5.1 version of the package today. Thanks for the great suggestion, and thank you @dreisenberger again for all of your hard work to add this feature and context flowing in general! |
@jmansar @johnmcase @tcsatheesh Blogged the pattern for using this for RetryAfter: http://www.thepollyproject.org/2017/05/04/putting-the-context-into-polly/ . Shout if any questions/suggestions. Intend to break out the blogged Use Cases also into separate How to sections of the wiki. This also makes a great case study for building your own custom policy: intending to blog/wiki how to build a custom policy that wraps all this functionality round WaitAndRetry (rather than you having to write the |
@jmansar @johnmcase @tcsatheesh Polly v5.6.0 (uploading to nuget in next day or so) will include the ability for This should make it even easier to use |
Hi,
I have a small enhancement idea.
Currently the
sleepDurationProvider
function in theRetryWithSleep
policy doesn't have access to the result of the executed action. The only value passed to thesleepDurationProvider
is the retry count.I have a scenario where it would be quite useful to know the result in the wait time calculation function.
Scenario
There is an API, which I call in my application. It returns the error response with the
Retry-After
HTTP header set, when client exceeds the request rate limit or it is temporarily unavailable.The header contains number of seconds the client should wait before repeating the request.
It should be possible to use that value as a wait time.
Could you extend the sleepDurationProvider function to include the result from the executed action?
The text was updated successfully, but these errors were encountered: