Last active
January 11, 2021 15:02
-
-
Save rahulsahay19/f349096a47101c2359242cca3eaf0cca to your computer and use it in GitHub Desktop.
Policies.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy() | |
{ | |
return HttpPolicyExtensions.HandleTransientHttpError() | |
.WaitAndRetryAsync(5, | |
retryAttempt => TimeSpan.FromMilliseconds(Math.Pow(2, retryAttempt) * 1000), | |
(_, waitingTime) => | |
{ | |
Console.WriteLine("Retrying....."); | |
}); | |
} | |
private static IAsyncPolicy<HttpResponseMessage> GetCircuitBreakerPolicy() | |
{ | |
return HttpPolicyExtensions | |
.HandleTransientHttpError() | |
.CircuitBreakerAsync(3, TimeSpan.FromSeconds(10)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment