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

[Docs] Add clarification about property precedence #1918

Merged
merged 18 commits into from
Jan 24, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ If the `ShouldHandle` predicate returns `true` and the next attempt number is no

There are many properties that may contribute to this calculation:

- `BackoffType`: It specifies which calculation algorithm should run.
- `Delay`: If only this one is specified then it will be used as is. If others are defined as well then this will be used as a *base delay*.
- `DelayGenerator`: If specified then it will overwrite other properties based calculation. **Except** if it returns a negative `TimeSpan` where the other properties based calculation is used.
- `MaxDelay`: If specified then it caps the delay if the calculated one is greater than this value. **Except** if `DelayGenerator` is used where no capping is applied.
- `UseJitter`: If enabled then it adds a random value between between -25% of `Delay` and +25% of `Delay`. **Except** if `BackoffType` is set to `Exponential` where jitter is always used.
- `BackoffType`: Specifies which calculation algorithm should run.
- `Delay`: If only this property is specified then it will be used as-is. If others are also specified then this will be used as a *base delay*.
- `DelayGenerator`: If specified, will override other property-based calculations, **except** if it returns a negative `TimeSpan`, in which case the other property-based calculations are used.
- `MaxDelay`: If specified, caps the delay if the calculated delay is greater than this value, **except** if `DelayGenerator` is used, where no capping is applied.
- `UseJitter`: If enabled, then adds a random value between between -25% of `Delay` and +25% of `Delay`, **except** if `BackoffType` is `Exponential`, where a bit more complex jitter calculation is used.

> [!IMPORTANT]
> The summarized description below is an implementation detail. It may change in the future without notice.
Expand Down Expand Up @@ -150,6 +150,19 @@ Step 3: Using the generator if supplied

### Linear

This algorithm increases the delays for every attempt in a linear fashion if no jitter is used.

Step 1: Calculating the base delay:

- If `UseJitter` is set to `false` and `Delay` is specified then `Delay` multiplied by the actual attempt number will be used.
- If `UseJitter` is set to `true` and `Delay` is specified then a random value is added to the `Delay` multiplied by the actual attempt number.
- The random value is between -25% of the newly calculated `Delay` and +25% of the newly calculated `Delay`.
peter-csala marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> Because the jitter calculation is based on the newly calculated delay that's why the new delay could be smaller than the previous one.
peter-csala marked this conversation as resolved.
Show resolved Hide resolved

Step 2 and 3 are the same as for the Constant algorithm.

### Exponential

> [!TIP]
Expand Down