Ejemplo n.º 1
0
 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);
     }));
 }
Ejemplo n.º 2
0
 public static AsyncCircuitBreakerPolicy <HttpResponseMessage> GetHttpCircuitBreakerPolicy(ILogger logger, ICircuitBreakerPolicyConfig circuitBreakerPolicyConfig)
 {
     return(HttpPolicyBuilders.GetBaseBuilder()
            .CircuitBreakerAsync(circuitBreakerPolicyConfig.RetryCount,
                                 TimeSpan.FromSeconds(circuitBreakerPolicyConfig.BreakDuration),
                                 (result, breakDuration) =>
     {
         OnHttpBreak(result, TimeSpan.FromSeconds(circuitBreakerPolicyConfig.BreakDuration), circuitBreakerPolicyConfig.RetryCount, logger);
     },
                                 () =>
     {
         OnHttpReset(logger);
     }));
 }