-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Calculated break duration for Circuit breaker #1776
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
Merged
Merged
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
9d45467
Add BreakDurationGenerator
atawLee 4880911
Add Duration Generator UnitTest
atawLee 5752bb6
Apply suggestions from code review
atawLee 9e2e5f2
Merge branch 'main' into DurationGenerator
jognhoonlee 22e2590
Add BreakDurationGeneratorArguments
atawLee 29942be
Update circuit-breaker.md
atawLee 030b234
Update circuit-breaker.md
atawLee b924728
remove duplicate
atawLee 8f9a594
Add BreakDurationGenerator
atawLee b9023aa
Add Duration Generator UnitTest
atawLee 31ff325
Apply suggestions from code review
atawLee 2faadbd
Add BreakDurationGeneratorArguments
atawLee 491c99f
Update document circuit-breaker.md
atawLee f071d23
Merge branch 'DurationGenerator' of https://github.com/atawLee/Polly …
atawLee 9d2ae69
fix document
atawLee b6a8948
Update Document
atawLee a1c8474
Update CircuitBreaker Document
atawLee 92ec473
Merge branch 'App-vNext:main' into DurationGenerator
atawLee e24ab51
Apply suggestions from code review
atawLee 39c4721
Apply suggestions from code review
atawLee 5f7095d
Merge branch 'App-vNext:main' into DurationGenerator
atawLee 51620d7
Merge branch 'App-vNext:main' into DurationGenerator
atawLee 92de086
update document
atawLee 3685e9d
Merge branch 'DurationGenerator' of https://github.com/atawLee/Polly …
atawLee 8e5f803
controller - Add context
atawLee 8a82bf0
update unittest
atawLee cf02659
Apply suggestions from code review
atawLee f55b6aa
Merge branch 'App-vNext:main' into DurationGenerator
atawLee efcb36b
Reflect 'ValueTask' requirements
atawLee fc80c3e
Fixed warning
atawLee 5b1a882
Fixed Warning
atawLee 6962659
update PublishAPI
atawLee 5355b3e
Fixed Unittest
atawLee 5448c32
Delete Korean Comment
atawLee 1e32edd
Pull MainBranch
atawLee e4c3c7b
Pull Main Branch
atawLee 7044ed4
Merge Main Branch
atawLee 8867436
Update Test Coverage
atawLee fb81ee6
Apply suggestions from code review
atawLee 01b35fc
#pragma warning disable S1226
atawLee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/Polly.Core/CircuitBreaker/BreakDurationGeneratorArguments.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| namespace Polly.CircuitBreaker; | ||
| #pragma warning disable CA1815 // Override equals and operator equals on value types | ||
| /// <summary> | ||
| /// Represents arguments used to generate a dynamic break duration for a circuit breaker. | ||
| /// </summary> | ||
| public readonly struct BreakDurationGeneratorArguments | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="BreakDurationGeneratorArguments"/> struct. | ||
| /// </summary> | ||
| /// <param name="failureRate">The failure rate at which the circuit breaker should trip. | ||
| /// It represents the ratio of failed actions to the total executed actions.</param> | ||
| /// <param name="failureCount">The number of failures that have occurred. | ||
| /// This count is used to determine if the failure threshold has been reached.</param> | ||
| /// <param name="context">The resilience context providing additional information | ||
| /// about the execution state and failures.</param> | ||
| public BreakDurationGeneratorArguments( | ||
| double failureRate, | ||
| int failureCount, | ||
| ResilienceContext context) | ||
| { | ||
| FailureRate = failureRate; | ||
| FailureCount = failureCount; | ||
| Context = context; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the failure rate that represents the ratio of failures to total actions. | ||
| /// </summary> | ||
| public double FailureRate { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the count of failures that have occurred. | ||
| /// </summary> | ||
| public int FailureCount { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the context that provides additional information about the resilience operation. | ||
| /// </summary> | ||
| public ResilienceContext Context { get; } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| namespace Polly.CircuitBreaker.Health; | ||
|
|
||
| internal readonly record struct HealthInfo(int Throughput, double FailureRate) | ||
| internal readonly record struct HealthInfo(int Throughput, double FailureRate, int FailureCount) | ||
| { | ||
| public static HealthInfo Create(int successes, int failures) | ||
| { | ||
| var total = successes + failures; | ||
| if (total == 0) | ||
| { | ||
| return new HealthInfo(0, 0); | ||
| return new HealthInfo(0, 0, failures); | ||
| } | ||
|
|
||
| return new(total, failures / (double)total); | ||
| return new(total, failures / (double)total, failures); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments.BreakDurationGeneratorArguments() -> void | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments.BreakDurationGeneratorArguments(double failureRate, int failureCount, Polly.ResilienceContext! context) -> void | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments.Context.get -> Polly.ResilienceContext! | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments.FailureCount.get -> int | ||
| Polly.CircuitBreaker.BreakDurationGeneratorArguments.FailureRate.get -> double | ||
| Polly.CircuitBreaker.CircuitBreakerStrategyOptions<TResult>.BreakDurationGenerator.get -> System.Func<Polly.CircuitBreaker.BreakDurationGeneratorArguments, System.Threading.Tasks.ValueTask<System.TimeSpan>>? | ||
| Polly.CircuitBreaker.CircuitBreakerStrategyOptions<TResult>.BreakDurationGenerator.set -> void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.