public HttpClientPollyPolicy AddWaitRetryPolicy(int retryCount) { if (!_policies.ContainsKey(RetryKey)) { var policy = HttpClientPolicyBuilder.WaitAndRetryAsync(retryCount, ExponentialBackoffTimespan) .WithPolicyKey(RetryKey); _policies.Add(RetryKey, policy); } return(this); }
public HttpClientPollyPolicy AddFallbackPolicy(Func <Task <HttpResponseMessage> > action) { if (!_policies.ContainsKey(FallbackKey)) { var policy = HttpClientPolicyBuilder .Or <TimeoutRejectedException>() .Or <BrokenCircuitException>() .FallbackAsync(cancellationToken => action()) .WithPolicyKey(FallbackKey); _policies.Add(FallbackKey, policy); } return(this); }