Skip to content

Calculated break duration for Circuit breaker #1715

Closed
atawLee wants to merge 0 commit into
App-vNext:mainfrom
atawLee:DurationGenerator
Closed

Calculated break duration for Circuit breaker #1715
atawLee wants to merge 0 commit into
App-vNext:mainfrom
atawLee:DurationGenerator

Conversation

@atawLee
Copy link
Copy Markdown
Contributor

@atawLee atawLee commented Oct 22, 2023

Pull Request

The issue or feature being addressed

#653

Details on the issue fix or feature implementation

  • Added a FailureCount get property to CircuitBehavior to retrieve the count of failures.
  • Introduced a private readonly field _breakDurationGenerator of type Func<int, TimeSpan> to CircuitStateController for dynamic break duration generation.
  • Enhanced the constructor of CircuitStateController with an overload to accommodate _breakDurationGenerator.
  • Incorporated FailureCount into HealthInfo.
  • Updated OpenCircuitFor_NeedsLock to assign the _blockedUntil value based on both the presence of breakDuration and the number of failures.

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

@atawLee
Copy link
Copy Markdown
Contributor Author

atawLee commented Oct 22, 2023

@dotnet-policy-service agree

Comment thread src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Health/HealthInfo.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Health/HealthInfo.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Health/RollingHealthMetricsTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs
@peter-csala
Copy link
Copy Markdown
Contributor

Please also update the related anti-pattern under the circuit breaker docs.

Comment thread docs/strategies/circuit-breaker.md
Comment thread docs/strategies/circuit-breaker.md Outdated
Comment thread docs/strategies/circuit-breaker.md Outdated
Comment thread src/Snippets/Docs/CircuitBreaker.cs Outdated
Comment thread src/Snippets/Docs/CircuitBreaker.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread docs/strategies/circuit-breaker.md Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Controller/CircuitStateController.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/Health/HealthInfo.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Comment thread src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs Outdated
Copy link
Copy Markdown
Member

@martincostello martincostello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the build locally and fix the analyser warnings that are reported to you, such as code formatting issues and the Public API Analyser warnings. Opening the code with Visual Studio should provide you with gestures on the analyzer warnings to automatically update the appropriate files.

Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/AdvancedCircuitBehaviorTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Health/RollingHealthMetricsTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
Comment thread test/Polly.Core.Tests/CircuitBreaker/Controller/CircuitStateControllerTests.cs Outdated
@martincostello
Copy link
Copy Markdown
Member

The build is now complaining about not all of the changes' code paths being covered by a test.

You can use the coverage report attached to the build artifacts to take a look at what is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants