Comments (7)
SlyNet,
You could do this
Policy.Handle<Exception>(ex => !(exception is OperationCancelledException))
from polly.
Hi @kbabiy (Michael Wolfenden has stepped back from Polly by the way; the AppvNext team have now taken stewardship.)
I'll reflect further on an .Except(...)
feature: I can see a syntax like this would suit some situations.
Aspects to think through would be how it played alongside the existing syntax. For instance, what would be meant by the following?
Policy
.Handle<X>()
.Or<Y>()
.Except<A>()
.Or<B>()
Should B
be taken to be excluded or included by that? (And would the decision be clear to all users, whichever we chose?). It would probably be clearer to say that 'whitelisting' and 'blacklisting' exceptions could not be mixed, and 'all except' was an entirely alternative fluent stream. eg
Policy
.HandleAllExcept<X>()
.Or<Y>(); // Clearer here that Y is not handled?
We'd also then need a way to combine that with the fact that Polly can also now handle return results. We probably wouldn't want to mix blacklisting and whitelisting in the same syntax, so result-handling would have to follow the 'all except' pattern too.
Policy
.HandleAllExcept<X>()
.Or<Y>()
.AndAllResultsExcept<TResult>(...)
.OrResult<TResult>(...) // etc
Beginning to become quite complex to follow ...
We always have to consider whether extra API surface/complication adds sufficient benefit ... jury slightly still out for me on this one, given that there is already a workround (and taking into account the complex play with handling results). Very happy however for further community feedback on this.
from polly.
Yes, thanks. But fluent interface like Handle<Exception>().Except<OperationCancelledException>
would be readable?
from polly.
SlyNet,
Thanks for you input, I will consider adding this. In the meantime, If you wanted to, your could add this as an extension method in your code.
from polly.
Hi, Michael
Something like .Except looks like a good feature to me as well.
Common case I have came across is not wanting to retry on Timeout.
Reasonings are:
- Timeout quite probably means that requested resource is in trouble (working on top of its capacity) and adding retries makes things even worse (puts more stress on the resource already in stress, opens more long-hanging connections etc.)
- You probably already don't need the result after (retryCount + 1)x timeouts has passed
Could you probably suggest better solution to handling this type of situation?
Thank you.
from polly.
@kbabiy Regarding other ways to handle the scenario:
Timeout quite probably means that requested resource is in trouble (working on top of its capacity)
and adding retries makes things even worse
... you have described the classic case for using a CircuitBreaker
wrapping (or wrapped by) the Retry
policy. See the very similar description about when retries become counter-productive, in the introductions to Retry and CircuitBreaker in the wiki.
Perhjaps consider wrapping a CircuitBreaker (perhaps breaking specifically on TimeoutException
) in with your Retry.
from polly.
Hi, @reisenberger
Thank you for suggestion about CircuitBreaker. I know of this concept and reviewed it again after your suggestion, but i think it doesn't exactly fit (seems to be too radical) in my case, though generally makes a lot of sense in the similar scenarios.
As far as i understand problem with the Except
originally proposed probably comes from the existing Or
API being the only option to extend the Handle
clause - therefore adding any And-like condition (like Except
, AndNot
, And
etc.) leads to the unnecessary complex binary expressions being possible
Therefore adding the blacklisting approach (like HandleAllExcept
) looks like a cleaner solution, even though needing symmetrical changes in the results handling (which probably also makes sense to extend with blacklisting).
Hopefully the benefit of such changes will overweight the needed API complications
from polly.
Related Issues (20)
- [Feature request]: Integrate / add support for Lunar Proxy (backend resilience strategy) HOT 3
- [Question]: How can I suppress Execution Attempt log when using Polly V8 ResiliencePipelineBuilder? HOT 2
- [Bug]: ResiliencePipeline CircuitBreaker doesn't handle Half Open State Correctly when probing call throws unhandeled exception - half open state can never be left again HOT 8
- [Question]: Combine WaitAndRetry with WaitAndRetryForever HOT 6
- [Feature request]: Add TimeProvider argument to resilience extension methods HOT 5
- [Feature request]: Add AddStrategy API with no options HOT 3
- [Feature request]: No explicit timeout in new regex functionality HOT 1
- [Question]: DelegateResult.Result with Policy.HandleResult. HOT 6
- [Question]: Request services from `AddTransientHttpErrorPolicy` HOT 2
- Refresh Authorization Code on When.All (causing multiple refresh authentications) HOT 13
- [Bug]: Pipeline disposed and cannot be used anymore HOT 16
- [Question]: Primary Hedging Resiliency Context not being propagated to Action Context? HOT 1
- [Question]: Usage of ExecuteOutcomeAsync HOT 8
- [Feature request]: StrategyHelper, DisposeHelper, TimeProviderExtensions, TaskHelper should be public not internal HOT 6
- [Question]: Mock Policy Timing behaviour HOT 3
- [Question]: How to use ExecuteAsync In VB.Net? HOT 8
- [Question]: How to respect 429 errors and Retry-After headers in Polly v8? HOT 14
- Remove polyfill packages HOT 7
- Deprecate all packages which are no longer maintained HOT 5
- Consider making Polly easier to consume from F# and Visual Basic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polly.