Skip to content

Commit

Permalink
[Docs] Fix the policywrap sample (#1728)
Browse files Browse the repository at this point in the history
* Fix the policywrap sample

* Fix arrows

* Wrap related comments are fixed
  • Loading branch information
peter-csala authored Oct 29, 2023
1 parent a847c9f commit 94e23aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions docs/migration-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ IAsyncPolicy retryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(3, _ =>

IAsyncPolicy timeoutPolicy = Policy.TimeoutAsync(TimeSpan.FromSeconds(3));

// Wrap the policies. The policies are executed in the following order (i.e. Last-In-First-Out):
// 1. Retry
// 2. Timeout
IAsyncPolicy wrappedPolicy = Policy.WrapAsync(timeoutPolicy, retryPolicy);
// Wrap the policies. The policies are executed in the following order:
// 1. Retry <== outer
// 2. Timeout <== inner
IAsyncPolicy wrappedPolicy = Policy.WrapAsync(retryPolicy, timeoutPolicy);
```
<!-- endSnippet -->

Expand All @@ -169,9 +169,9 @@ In v8, there's no need to use policy wrap explicitly. Instead, policy wrapping i

<!-- snippet: migration-policy-wrap-v8 -->
```cs
// The "PolicyWrap" is integrated directly. Strategies are executed in the same order as they were added (i.e. First-In-First-Out):
// 1. Retry
// 2. Timeout
// The "PolicyWrap" is integrated directly. The strategies are executed in the following order:
// 1. Retry <== outer
// 2. Timeout <== outer
ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
.AddRetry(new()
{
Expand All @@ -185,8 +185,8 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
```
<!-- endSnippet -->

> [!IMPORTANT]
> In v7, the policy wrap ordering is different; the policy added first was executed last (FILO). In v8, the execution order matches the order in which they were added (FIFO). See [fallback after retries](strategies/fallback.md#fallback-after-retries) for an example on how the strategies are executed.
> [!NOTE]
> See [fallback after retries](strategies/fallback.md#fallback-after-retries) for an example on how the strategies are executed.
## Migrating retry policies

Expand Down
14 changes: 7 additions & 7 deletions src/Snippets/Docs/Migration.Wrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public static void PolicyWrap_V7()

IAsyncPolicy timeoutPolicy = Policy.TimeoutAsync(TimeSpan.FromSeconds(3));

// Wrap the policies. The policies are executed in the following order (i.e. Last-In-First-Out):
// 1. Retry
// 2. Timeout
IAsyncPolicy wrappedPolicy = Policy.WrapAsync(timeoutPolicy, retryPolicy);
// Wrap the policies. The policies are executed in the following order:
// 1. Retry <== outer
// 2. Timeout <== inner
IAsyncPolicy wrappedPolicy = Policy.WrapAsync(retryPolicy, timeoutPolicy);

#endregion
}
Expand All @@ -22,9 +22,9 @@ public static void PolicyWrap_V8()
{
#region migration-policy-wrap-v8

// The "PolicyWrap" is integrated directly. Strategies are executed in the same order as they were added (i.e. First-In-First-Out):
// 1. Retry
// 2. Timeout
// The "PolicyWrap" is integrated directly. The strategies are executed in the following order:
// 1. Retry <== outer
// 2. Timeout <== outer
ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
.AddRetry(new()
{
Expand Down

0 comments on commit 94e23aa

Please sign in to comment.