-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Docs] Add clarification about property precedence #1918
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
martintmk
merged 18 commits into
App-vNext:main
from
peter-csala:update-doc-to-clarify-precedence
Jan 24, 2024
Merged
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f7b6a6c
Add clarification
peter-csala a79988d
Fix copy-paste issue
peter-csala 106df37
Add description about constant backoff
peter-csala 9345f5f
Fix spellcheck
peter-csala a1515c8
Apply suggestions from code review
peter-csala 4607b93
Apply suggestions from code review
peter-csala aef2b88
Add description to each property
peter-csala eb4b475
Fix markdown lint issue
peter-csala d28bd3e
Apply suggestions from code review
peter-csala 027c732
Fix markdown lint issue
peter-csala 1e71491
Add description about linear backoff
peter-csala 7ad36e0
Fix spellcheck issue
peter-csala 4614dcb
Add description about exponential backoff
peter-csala dfbfb3d
Add examples
peter-csala 62665fa
Apply suggestion
peter-csala 8cf291a
Apply suggestion
peter-csala e39d09c
Correct null return value handling for DelayGenerator
peter-csala 622cecc
Fix broken link
peter-csala 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
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ deserialization | |
dotnet | ||
dotnetrocks | ||
durations | ||
enum | ||
eshoponcontainers | ||
extensibility | ||
flurl | ||
|
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -108,6 +108,55 @@ new ResiliencePipelineBuilder<HttpResponseMessage>().AddRetry(optionsExtractDela | |||||||||
| `OnRetry` | `null` | Action executed when retry occurs. | | ||||||||||
| `MaxDelay` | `null` | Caps the calculated retry delay to a specified maximum duration. | | ||||||||||
|
||||||||||
## Calculation of the next delay | ||||||||||
|
||||||||||
If the `ShouldHandle` predicate returns `true` and the next attempt number is not greater than `MaxRetryAttempts` then the retry strategy calculates the next delay. | ||||||||||
|
||||||||||
There are many properties that are somehow contribute to this calculation: | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
- `Delay` | ||||||||||
- `DelayGenerator` | ||||||||||
- `MaxDelay` | ||||||||||
- `UseJitter` | ||||||||||
- `BackoffType` | ||||||||||
|
||||||||||
> [!IMPORTANT] | ||||||||||
> The below described algorithm is an implementation detail. It might change in the future without further notice. | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
> | ||||||||||
> Also please bear in mind that some details are not mentioned here to keep the algorithm description short and terse. | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
The `BackoffType` property's data type is a [`DelayBackOffType`](xref:Polly.DelayBackOffType) enum. This controls primarily how the calculation is done. | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
### Constant | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Or something in that sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
|
||||||||||
One might think that here we only put into the account the `Delay` property. In reality all above listed properties are used. | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
Step 1: Calculating the base delay: | ||||||||||
|
||||||||||
- If `UseJitter` is set to `false` and `Delay` is specified then `Delay` will be used. | ||||||||||
- If `UseJitter` is set to `true` and `Delay` is specified then a random value is added to the `Delay`. | ||||||||||
- The random value is between [-25% of `Delay`, +25% of `Delay`]. | ||||||||||
peter-csala marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
Step 2: Capping the delay if needed: | ||||||||||
|
||||||||||
- If the previously calculated delay is greater than `MaxDelay` then `MaxDelay` will be used. | ||||||||||
|
||||||||||
Step 3: Using the generator if supplied | ||||||||||
|
||||||||||
- If the returned `TimeSpan` of the `DelayGenerator` method call is positive then it will be used. | ||||||||||
- If the returned `TimeSpan` of the `DelayGenerator` method call is negative then it will use the step 2's result. | ||||||||||
|
||||||||||
> [!NOTE] | ||||||||||
> The `DelayGenerator`'s returned value is not capped with the `MaxDelay`. | ||||||||||
|
||||||||||
### Linear | ||||||||||
|
||||||||||
### Exponential | ||||||||||
|
||||||||||
> [!TIP] | ||||||||||
> For more details please check out the [`RetryHelper`](https://github.com/App-vNext/Polly/blob/main/src/Polly.Core/Retry/RetryHelper.cs) | ||||||||||
> and the [`RetryResilienceStrategy`](https://github.com/App-vNext/Polly/blob/main/src/Polly.Core/Retry/RetryResilienceStrategy.cs) classes. | ||||||||||
|
||||||||||
## Diagrams | ||||||||||
|
||||||||||
Let's suppose we have a retry strategy with `MaxRetryAttempts`: `2`. | ||||||||||
|
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.