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 1 commit
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
13 changes: 7 additions & 6 deletions docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@

There are many properties that may contribute to this calculation:

- `Delay`
- `DelayGenerator`
- `MaxDelay`
- `UseJitter`
- `BackoffType`
- `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.
peter-csala marked this conversation as resolved.
Show resolved Hide resolved
- `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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `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.
- `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.

Just wondering, shall we apply the capping to values produced by generator too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say yes. That was my intuition before I checked the implementation. But let's deal with that in a separate PR if you don't mind.

Copy link
Contributor

@martintmk martintmk Jan 24, 2024

Choose a reason for hiding this comment

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

My intuition says yes too, the less special cases, the better. The only downside is that sometimes the Retry-After won't be fully respected if the value is greater than MaxDelay.

https://github.com/dotnet/extensions/blob/9f25d9d74674483298cd167cf8ff6e9d9026bf20/src/Libraries/Microsoft.Extensions.Http.Resilience/Polly/HttpRetryStrategyOptions.cs#L57

Thoughts @martincostello

Copy link
Member

Choose a reason for hiding this comment

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

I would agree we should apply it - Retry-After isn't necessarily authoritative and the user may wish to try earlier by overriding. If we do that we should make it clear in the documentation.

Copy link
Contributor Author

@peter-csala peter-csala Jan 24, 2024

Choose a reason for hiding this comment

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

It is a concision decision by the strategy configurator that (s)he sets the MaxDelay. If it is set then the strategy should cap the value regardless how it is calculated/retrieved IMHO.

- `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.
peter-csala marked this conversation as resolved.
Show resolved Hide resolved
peter-csala marked this conversation as resolved.
Show resolved Hide resolved

> [!IMPORTANT]
> The summarized description below is an implementation detail. It may change in the future without notice.
Expand All @@ -137,7 +137,8 @@

Step 2: Capping the delay if needed:

- If the previously calculated delay is greater than `MaxDelay` then `MaxDelay` will be used.
- If `MaxDelay` is not set then the previously calculated delay will be used.
- If `MaxDelay` is set and the previously calculated delay is greater than `MaxDelay` then `MaxDelay` will be used.

Step 3: Using the generator if supplied

Expand Down Expand Up @@ -338,7 +339,7 @@

✅ DO

Use a suitable tool to schedule recurring tasks, such as [*Quartz.Net*](https://www.quartz-scheduler.net/), [*Hangfire*](https://www.hangfire.io/), or others.

Check failure on line 342 in docs/strategies/retry.md

View workflow job for this annotation

GitHub Actions / publish-docs

Emphasis style

docs/strategies/retry.md:342:59 MD049/emphasis-style Emphasis style [Expected: underscore; Actual: asterisk] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md

Check failure on line 342 in docs/strategies/retry.md

View workflow job for this annotation

GitHub Actions / publish-docs

Emphasis style

docs/strategies/retry.md:342:70 MD049/emphasis-style Emphasis style [Expected: underscore; Actual: asterisk] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md

Check failure on line 342 in docs/strategies/retry.md

View workflow job for this annotation

GitHub Actions / publish-docs

Emphasis style

docs/strategies/retry.md:342:110 MD049/emphasis-style Emphasis style [Expected: underscore; Actual: asterisk] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md

Check failure on line 342 in docs/strategies/retry.md

View workflow job for this annotation

GitHub Actions / publish-docs

Emphasis style

docs/strategies/retry.md:342:119 MD049/emphasis-style Emphasis style [Expected: underscore; Actual: asterisk] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md

**Reasoning**:

Expand Down
Loading