Fauna v10 .NET/C# Driver 0.2.0-beta
 
Loading...
Searching...
No Matches
RetryConfiguration.cs
Go to the documentation of this file.
1using System.Net;
2using Polly;
3
4namespace Fauna;
5
10{
11
15 public AsyncPolicy<HttpResponseMessage> RetryPolicy { get; set; }
16
17
23 public RetryConfiguration(int retryCount, TimeSpan maxBackoff)
24 {
25 RetryPolicy = Policy
26 .HandleResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.TooManyRequests)
27 .WaitAndRetryAsync(retryCount, attempt =>
28 {
29 var calculated = (int)Math.Floor(Math.Pow(2, attempt));
30 var backoff = calculated > maxBackoff.Seconds ? maxBackoff.Seconds : calculated;
31 return TimeSpan.FromSeconds(backoff);
32 });
33 }
34
35}
A class representing a retry configuration for queries.
RetryConfiguration(int retryCount, TimeSpan maxBackoff)
Creates a new RetryConfiguration instance.
AsyncPolicy< HttpResponseMessage > RetryPolicy
Gets the retry policy.
Definition Client.cs:8