Exemplo 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);
     }));
 }
Exemplo n.º 2
0
 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);
     }));
 }