[NuGet]: Polly
This is a Nuget that I use in all projects when I am making HTTP calls..
Link: https://www.nuget.org/packages/polly
Site: https://github.com/App-vNext/Polly
What it does: Implements all kind of policies for retrying – see https://github.com/App-vNext/Polly/wiki/Transient-fault-handling-and-proactive-resilience-engineering
Usage: – copied from https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
{
return HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2,
retryAttempt)));
}
Leave a Reply