Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polly's Circuit Breaker and Azure client SDKs #162

Closed
francischeung opened this issue Oct 6, 2016 · 2 comments
Closed

Polly's Circuit Breaker and Azure client SDKs #162

francischeung opened this issue Oct 6, 2016 · 2 comments
Labels

Comments

@francischeung
Copy link

Most of the Azure client SDKs perform their own retry logic. If I wanted to use Polly's circuit breaker with an Azure client, would you suggest that the Polly circuit breaker just detect exceptions that the Azure client raises?

            var breaker = Policy
              .Handle<DocumentClientException>()
              .CircuitBreakerAsync(2, TimeSpan.FromMinutes(1));

            await breaker.ExecuteAsync(async () =>
            {
                await documentClient.CreateDocumentAsync(documentCollectionUri, document);
            });
@reisenberger
Copy link
Member

reisenberger commented Oct 7, 2016

Hi @francischeung Yes, that's a completely valid way to proceed, to combine Polly's circuit-breaking with Azure's built-in retry logic, and your code sample looks perfect for this.


When Polly v5.0 is launched in the next four weeks or so, there may be other factors to consider regarding using Azure's retries versus Polly's. Polly v5.0 is adding a whole host of wider resilience features, and the ability to combine all those resilience strategies into a PolicyWrap. For certain combinations of Polly resilience strategies, the most logical place for retry is going to be somewhere in the middle of the policy wrap ... something like:

PolicyWrap wrap = Policy.Wrap(fallback, cache, retry, circuitBreaker, timeout, bulkhead);
await wrap.ExecuteAsync(async () => ... );

Placing a retry in the midst of Polly's (forthcoming) wider resilience strategies like this, could be done with Polly's Retry policies, but not with Azure's retry policies (you couldn't mix Polly's on both sides of Azure's). so at that point you might want to switch to Polly retry as well.

We are aiming to have v5.0 as an alpha nuget release in week beginning 24 October.

Hope this helps.

@reisenberger
Copy link
Member

Closing historic issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants