I am trying to wrap two Polly policies and want to return IAsyncPolicy
, but it giving error,
convert from Polly.Retry.RetryPolicy < System.Net.Http.HttpResponseMessage> to Polly.IAsyncPolicy
public static IAsyncPolicy CreateDefaultRetryPolicy()
{
var timeoutPolicy = Policy.TimeoutAsync(TimeSpan.FromSeconds(180));
var waitAndRetryPolicy = Polly.Policy
.Handle<HttpRequestException>()
.OrResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.InternalServerError)
.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(3, retryAttempt)),
(result, timeSpan, context) =>
{
});
return Policy.WrapAsync(timeoutPolicy, waitAndRetryPolicy);
}
How to wrap this and return?