This sample project was put together based on the following SO question.
- How to define separate circuit breaker policies for different domains?
- NOTE: For a single domain use the Circuit Breaker as a shared policy.
Use IDictionary
or IConcurrentPolicyRegistry
collections to store policies per domain
The implementation is simple, you have to populate a collection and look up the appropriate policy whenever needed
You have to explicitly call the retrieved policy's ExecuteAsync
Use named typed clients and decorate them with Circuit Breakers
The policy usage is done implicitly on your behalf
The setup part is a bit more complex compared to Option A
This sample project shows how to implement Option B
Clients
folder contains the definition of the typed client (interface + dummy implementation)Program.cs
contains the policy definitions and the registration of the named and typed clientsSampleController.cs
shows the usage of the named and typed clients