Comments (2)
Hey @IGx89
In Polly V8 there is no way to retrieve the circuit breaker state from an instance of ResiliencePipeline
. Even if enumerating pipeline from registry was available it wouldn't help.
What you want to do is to keep registry of CircuitBreakerStateProvider
as you are creating the pipelines. See this test that demonstrates your use-case:
// Arrange
var states = new ConcurrentBag<CircuitBreakerStateProvider>();
using var registry = new ResiliencePipelineRegistry<string>();
// Act
_ = registry.GetOrAddPipeline("A", builder =>
{
var stateProvider = new CircuitBreakerStateProvider();
builder.AddCircuitBreaker(new() { StateProvider = stateProvider });
states.Add(stateProvider);
});
_ = registry.GetOrAddPipeline("B", builder =>
{
var stateProvider = new CircuitBreakerStateProvider();
builder.AddCircuitBreaker(new() { StateProvider = stateProvider });
states.Add(stateProvider);
});
_ = registry.TryAddBuilder("C", (builder, _) =>
{
var stateProvider = new CircuitBreakerStateProvider();
builder.AddCircuitBreaker(new() { StateProvider = stateProvider });
states.Add(stateProvider);
});
// Assert
states.Should().HaveCount(2);
registry.GetPipeline("C");
states.Should().HaveCount(3);
foreach (var state in states)
{
state.CircuitState.Should().Be(CircuitState.Closed);
}
doesn't implement IEnumerable nor provides any way to get a list of the pipelines. Was that removed deliberately? If not, could that functionality be added back?
This was deliberate choice due to dynamic nature of registry. The pipelines are not explicitly added, instead these are created on demand when requested. Additionally, with the minimal nature of ResiliencePipeline
there is now way to retrieve any information about strategies from it.
Also created a PR that adds this test: #1829
from polly.
Thanks a lot for the detailed explanation and code example! That's very helpful. I definitely have a lot more learning to do it looks :)
from polly.
Related Issues (20)
- [Question]: Polly 8.2.0 Why Timeout not effective? HOT 9
- [Question]: Replacing ResiliencePipelineProvider with keyed services HOT 8
- [Bug]: ResiliencePipelineBuilder AddCircuitBreaker grows stacktrace uncontrollably HOT 11
- [Feature request]: Relax validation of TimeoutStrategyOptions.Timeout HOT 4
- how to use it for retry but not fault situation? HOT 10
- [Question]: Circuit Breaker: Using BreakDurationGenerator to implement exponential backoff of open to half-open state HOT 1
- [Question]: Polly v8.2.0 how to use AddRetry and AddFallback methods HOT 16
- Simmy API Review and Feedback HOT 32
- [Feature request]: Adding Polly.Telemetry event for being out of retries HOT 4
- [Question]: Is Polly compatible with Unity ? HOT 2
- [Question]: HOT 1
- [Question]: Complex Pipeline Keys documentation example not working as expected HOT 2
- [Question]: Migration from HOT 4
- [Bug]: Retry doesn't happen with FakeTimerProvider.Advance HOT 5
- [Feature request]: Integrate / add support for Lunar Proxy (backend resilience strategy) HOT 3
- [Question]: How can I suppress Execution Attempt log when using Polly V8 ResiliencePipelineBuilder? HOT 2
- [Bug]: ResiliencePipeline CircuitBreaker doesn't handle Half Open State Correctly when probing call throws unhandeled exception - half open state can never be left again HOT 8
- [Question]: Combine WaitAndRetry with WaitAndRetryForever HOT 6
- [Feature request]: Add TimeProvider argument to resilience extension methods HOT 5
- [Feature request]: Add AddStrategy API with no options HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polly.