As I understand it a Policy in Polly is thread safe and there should be only one shared instance of it.
So I guess that it would be safe to inject a singleton CB Policy in the controllers that needs to know if the circuit are open.
Am I right?
As I understand it a Policy in Polly is thread safe and there should be only one shared instance of it.
So I guess that it would be safe to inject a singleton CB Policy in the controllers that needs to know if the circuit are open.
Am I right?
As I understand it a Policy in Polly is thread safe
Correct.
and there should be only one shared instance of it.
I guess the statement 'should be only one shared instance' needs to be qualified somehow with 'shared across what?'. The correct scoping is share a policy instance across call sites you want to break in common - typically, call sites calling the same downstream system.
So I guess that it would be safe to inject a singleton CB Policy in the controllers that needs to know if the circuit are open.
It would be safe. Share or don't share the same instance across call sites as discussed above.
These questions/answers 1 2 and this in the Polly wiki are related.