By default the SDK supports Automatic Retries with Exponential Delay and Circuit Breaker.
The default configuration values for Retry and Circuit Breaker are the following:
Retry Configuration | |||
---|---|---|---|
Retry | Count | 3 | Retries 3 times |
DelayExponentialFactor | 2 | Wait time between retries is Math.Pow(2, retryAttempt) | |
Circuit Breaker Configuration | |||
CircuitBreaker | FailureThreshold | 0.7 | Break on >=70% actions result in handled exception |
SamplingDuration | TimeSpan.FromSeconds(60) | Over any 60 seconds period | |
MinimumThroughput | 16 | Provided at least 16 actions in the 60 seconds period | |
DurationOfBreak | TimeSpan.FromSeconds(60) | Break for 60 seconds |
If you want to change these values you will have to create your own Resilience configuration reference:
var configuration = new ResilienceConfiguration
{
Retry = new RetryConfiguration
{
Count = 5, // Retries 3 times
DelayExponentialFactor = 5 // Wait time between retries is Math.Pow(2, retryAttempt)
},
CircuitBreaker = new CircuitBreakerConfiguration
{
FailureThreshold = 0.5, // Break on >=50% actions result in handled exceptions
SamplingDuration = TimeSpan.FromSeconds(30), // over any 30 seconds period
MinimumThroughput = 10, // provided at least 10 actions in the 30 seconds period.
DurationOfBreak = TimeSpan.FromSeconds(90) // Break for 90 seconds.
}
};
};
var httpClientBuilder = new HttpClientBuilder(() => AuthenticationConfiguration).WithResilienceConfiguration(configuration);