Skip to content

A sample project to demonstrate how to define separate Circuit Breakers per domain

Notifications You must be signed in to change notification settings

peter-csala/Polly-Separate-Circuit-Breakers-per-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Polly usage example - Separate Circuit Breakers per domain

This sample project was put together based on the following SO question.

Problem (in short)

  • How to define separate circuit breaker policies for different domains?
  • NOTE: For a single domain use the Circuit Breaker as a shared policy.

Design

Option A

Use IDictionary or IConcurrentPolicyRegistry collections to store policies per domain

Pro

The implementation is simple, you have to populate a collection and look up the appropriate policy whenever needed

Con

You have to explicitly call the retrieved policy's ExecuteAsync

Option B

Use named typed clients and decorate them with Circuit Breakers

Pro

The policy usage is done implicitly on your behalf

Con

The setup part is a bit more complex compared to Option A

Solution

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 clients
  • SampleController.cs shows the usage of the named and typed clients

About

A sample project to demonstrate how to define separate Circuit Breakers per domain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages