WaitAndRetryForever variants: add overloads where onRetry takes retry number
See original GitHub issueMethod WaitAndRetryAsync
do have an override:
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, int, Context> onRetry)
allowing to log exception together with number of attempt during which it ocurred:
Policy
.Handle<ArgumentException>()
.WaitAndRetryAsync(10, (rn, ctx) => TimeSpan.FromSeconds(1),
(ex, ts, rc, ctx) => { Console.WriteLine($"Exception logged: {ex.GetType().Name}. Attempt: {rc}"); })
But method WaitAndRetryForeverAsync
does not have similar override. As a workaround I could use WaitAndRetryAsync
with int.MaxValue
as first argument, but that is not the best look and feel especially when we have Forever counterpart method.
As a solution I can propose either add the missing override, or add retryAttemptNumber to Context class. Latter option would also help when retry attempt is needed during main action execution (mainly for logging purposes).
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hi @NRKirby Thank you for your interest in this! @Freakazoid182 has made a PR ( #471 ) on this just hours earlier, so it may no longer be ‘up-for-grabs’. @Freakazoid182 / both: I haven’t had the chance to read #471 today, but will do shortly. @NRKirby Do feel free to read #471; comments welcome!
My pleasure @SashaPshenychniy and @reisenberger