-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How do i access the policies within PolicyWrap? #312
Comments
I don't believe PolicyWrap is exposing its inner policies, and I don't believe it should. In the end, it's just a new policy itself, which (recursively) wraps existing policy instances. If I understand your use case correctly, the FallbackPolicy instance is the actual object you want to access. Personally, I guess it shouldn't matter if it's wrapped or not, or even if it's re-used at many different locations. So rather than trying to find the policy through a PolicyWrap, I would suggest keeping track of the FallbackPolicy itself, regardless of where it's used. Perhaps you could use the PolicyRegistry and register the FallbackPolicy instance by name? Especially when using the PolicyRegistry in combination with DI, you could easily use the registry to find and access specific policy instances from anywhere within your application. Just my 2 cents. |
I need access to the CircuitBreaker within the PolicyWrap, not the Fallback. It's unfortunate that the inner policies aren't exposed as now I am forced to keep track of both the CircuitBreaker that's in the PolicyWrap and the PolicyWrap itself. I understand I can write my own implementation but I'd prefer to leverage something that's already an established pattern. BTW, I don't see anything wrong with adding some sort of GetPolicy(policyKey) method on PolicyWrap How do others keep track of the CircuitState when using a CircuitBreakerPolicy within a PolicyWrap? |
Yes sorry, I meant to say CircuitBreaker policy, not Fallback policy. |
Thank you @udlose and @ExtRemo75 for the great discussion on this! Decoupling of policy configuration from usage due to DI, or using @udlose Re How about an API which focuses simply on the essence of what PolicyWrap is: (1) read-only property From (3) anything like "extract the circuit-breaker" or "extract the Policy with this key" follows trivially with LINQ. The current What do you think? PR to implement this would be welcome! Cross-ref: https://stackoverflow.com/questions/45913775/ . (If we implement this, let's post also on that StackOverflow that it is done!) |
@reisenberger Couple of thoughts:
|
@udlose Agreed,
However, completely agree that So a revised overall API for this feature could be: (1)-(2)-(3) as per my previous comment. These are important as they form the logical converse to constructing the Plus: (4) And: [EDIT: For the reason you say, it would be useful to have this] (8) Thoughts? (Thanks for input so far, which is turning this into a better feature!) |
@reisenberger I think most of those are good. of course any method taking a param would have to have null param validation on it which would go for (5), (7), and (8) (where this includes null check and thoughts? |
Implemtation for App-vNext#312 from @MartinSStewart , Polly Knowabunga Hackathon at Tretton37
Implemtation for #312 from @MartinSStewart , Polly Knowabunga Hackathon at Tretton37
This feature is delivered in Polly v5.6.0 (will be released via nuget in next day or so). |
If i pass a couple of policies to PolicyWrap, I'd like to be able to access them - possibly by name? For example, i have a RetryPolicy, CircuitBreakerPolicy, and FallbackPolicy passed to a PolicyWrap. I'm storing a reference to the PolicyWrap instead of the individual policies. I'd like to be able to access the CircuitBreakerPolicy to check its CircuitState and call Isolate() and Reset().
I'm not able to find anything exposing the inner policies. Am I missing something?
The text was updated successfully, but these errors were encountered: