public static AsyncRetryPolicy <HttpResponseMessage> GetHttpRetryPolicy(ILogger logger, IRetryPolicyConfig retryPolicyConfig) { return(HttpPolicyBuilders.GetBaseBuilder() .WaitAndRetryAsync(retryPolicyConfig.RetryCount, ComputeDuration, (result, timeSpan, retryCount, context) => { OnHttpRetry(result, timeSpan, retryCount, context, logger); })); }
public static AsyncCircuitBreakerPolicy <HttpResponseMessage> GetHttpCircuitBreakerPolicy(ILogger logger, ICircuitBreakerPolicyConfig circuitBreakerPolicyConfig) { return(HttpPolicyBuilders.GetBaseBuilder() .CircuitBreakerAsync(circuitBreakerPolicyConfig.RetryCount + 1, TimeSpan.FromSeconds(circuitBreakerPolicyConfig.BreakDuration), (result, breakDuration) => { OnHttpBreak(result, breakDuration, circuitBreakerPolicyConfig.RetryCount, logger); }, () => { OnHttpReset(logger); })); }