Skip to content

Single HttpClient with several circuit breaker #1802

Answered by martintmk
joegoldman2 asked this question in Q&A
Discussion options

You must be logged in to vote

@joegoldman2

Is there any way to have a different circuit breaker for each backend that is consumed

This will work with a slight modification to your sample:

builder.Services
    .AddHttpClient("Default")
    .AddResilienceHandler("default", b =>
    {
        b.AddCircuitBreaker(new()
        {
            BreakDuration = TimeSpan.FromSeconds(5),
            FailureRatio = 0.1,
            MinimumThroughput = 100,
            SamplingDuration = TimeSpan.FromSeconds(30),
        });
    })
    .SelectPipelineByAuthority();

Notice the use of SelectPipelineByAuthority. This tells the handler to cache the pipeline by authority (scheme + host + port) extracted from request message. Effectiv…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by joegoldman2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants