Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BreakDurationGenerator not passed to CircuitStateController #1850

Closed
martincostello opened this issue Dec 11, 2023 · 2 comments · Fixed by #1852
Closed

BreakDurationGenerator not passed to CircuitStateController #1850

martincostello opened this issue Dec 11, 2023 · 2 comments · Fixed by #1852
Assignees
Labels
Milestone

Comments

@martincostello
Copy link
Member

          There is an issue with this. When you call AddCircuitBreaker(options), having specified BreakDurationGenerator. It does not pass the generate to the CircuitStateController. So the resulting circuitbreaker will use the default 5 seconds fixed duration.

Originally posted by @adminnz in #1776 (comment)

@adminnz
Copy link

adminnz commented Dec 11, 2023

Not sure what more to add, the BreakDurationGenerator does not get passed to the controller.

So if you do:

        ResiliencePipeline = new ResiliencePipelineBuilder()
           .AddCircuitBreaker(new CircuitBreakerStrategyOptions
           {
               BreakDurationGenerator = args => ValueTask.FromResult(TimeSpan.FromMinutes(args.FailureCount)),
               MinimumThroughput = Settings.CircuitBreakerMinimumThroughput,
               FailureRatio = Settings.CircuitBreakerFailureRatio,
               SamplingDuration = Settings.CircuitBreakerSamplingDuration,
               StateProvider = CircuitBreakerStateProvider,
               OnClosed = OnCircuitClosed,
               OnOpened = OnCircuitOpened,
               OnHalfOpened = OnHalfOpened
           })
           .Build();

The resulting ResiliencePipline circuit breaker will not use the BreakDurationGenerator. Instead it will use the default 5 second BreakDuration.

@martincostello
Copy link
Member Author

Thanks - it was a concrete code snippet I was after so that we can use it to build up a unit test.

@martincostello martincostello self-assigned this Dec 12, 2023
@martincostello martincostello added this to the v8.3.0 milestone Dec 12, 2023
martincostello added a commit to martincostello/Polly that referenced this issue Dec 12, 2023
Add an integration test for when `BreakDurationGenerator` is specified to guard against the issue reported by App-vNext#1850.
martincostello added a commit that referenced this issue Dec 12, 2023
Add an integration test for when `BreakDurationGenerator` is specified to guard against the issue reported by #1850.
martincostello added a commit that referenced this issue Jan 4, 2024
Add an integration test for when `BreakDurationGenerator` is specified to guard against the issue reported by #1850.
@martincostello martincostello modified the milestones: v8.3.0, v8.2.1 Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants