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

Reintroduce SleepDurationProvider DelegateResult<TREsult> overload on WaitAndRetryAsync #840

Closed
esbenbach opened this issue Apr 7, 2021 · 2 comments
Labels

Comments

@esbenbach
Copy link

esbenbach commented Apr 7, 2021

Is your feature request related to a specific problem? Or an existing feature? Please describe.

I am trying to handle HTTP 429 as discussed in #414 - specifically using the sleepdurationprovider overload that takes DelegateResult<TResult> as an input.

It seems like this used to exist:

public static RetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount,

It "seems" to exist on WaitAndRetryForeverAsync - but i don't want to wait forever :)

Describe your proposed or preferred solution:

Add a new overload that allows me to examine the result in the sleepdurationprovider :)

Describe any alternative options you've considered:

My workaround is to "hack" it by placing the wait logic inside the onRetry

@martincostello
Copy link
Member

Which version of Polly are you using?

This method still exists in the latest release, it's just that the return type is different for async policies now.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount,
Func<int, DelegateResult<TResult>, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

@esbenbach
Copy link
Author

I am running on polly 7.1.0. Tried upgrading to 7.2.2. Which does seem to have the mentioned overload. Not really sure why I didnt try that before.

I guess we can just close this again :)

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

No branches or pull requests

2 participants