I'm replacing my currenty retry policies with the Polly framework. I used to define my retry strategy like this:
var strategy = new ExponentialBackoff(RetryStrategy.DefaultClientRetryCount, RetryStrategy.DefaultMinBackoff, RetryStrategy.DefaultMaxBackoff, RetryStrategy.DefaultClientBackoff);
where the DefaultClientRetryCount
is the number of retries
and then the exponentialBackoff calculates the sleep time between the retries based on the variables: DefaultMinBackoff
is the min timespan between retries; DefaultMaxBackoff
is the maximum timespan; and DefaultClientBackoff
is a default value used to calculate a random delta between retries.
On Polly I define my retryPolicy like this:
var retryPolicy = Policy.Handle<Exception>(ex => _transientErrorDetectionStrategy.IsTransient(ex)).WaitAndRetryAsync(int retryCount, Func<int,timespan> sleepDuration);
Where the retryCount
is the number of retries and the sleepDuration
is the time between retries.
How can I replicate the Timespan between retries generated on the previous policy to send as parameter to the WaitAndRetryAsync
method on Polly?