Fauna .NET Driver 0.1.0-beta
 
Loading...
Searching...
No Matches
RetryConfiguration.cs
Go to the documentation of this file.
1using System.Net;
2using Polly;
3
4namespace Fauna;
5
7{
8
12 public AsyncPolicy<HttpResponseMessage> RetryPolicy { get; set; }
13
14
20 public RetryConfiguration(int retryCount, TimeSpan maxBackoff)
21 {
22 RetryPolicy = Policy
23 .HandleResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.TooManyRequests)
24 .WaitAndRetryAsync(retryCount, attempt =>
25 {
26 var calculated = (int)Math.Floor(Math.Pow(2, attempt));
27 var backoff = calculated > maxBackoff.Seconds ? maxBackoff.Seconds : calculated;
28 return TimeSpan.FromSeconds(backoff);
29 });
30 }
31
32}
RetryConfiguration(int retryCount, TimeSpan maxBackoff)
Creates a new RetryConfiguration object.
AsyncPolicy< HttpResponseMessage > RetryPolicy
Async retry policy.
Definition Client.cs:9