You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/migration-v8.md
+108-51
Original file line number
Diff line number
Diff line change
@@ -409,7 +409,7 @@ new ResiliencePipelineBuilder<HttpResponseMessage>().AddRetry(new RetryStrategyO
409
409
> Things to remember:
410
410
>
411
411
> - Use `AddRetry` to add a retry strategy to your resiliency pipeline
412
-
> - Use the `RetryStrategyOptions` to customize your retry behavior to meet your requirements
412
+
> - Use the `RetryStrategyOptions{<TResult>}` to customize your retry behavior to meet your requirements
413
413
>
414
414
> For further information please check out the [Retry resilience strategy documentation](strategies/retry.md).
415
415
@@ -689,7 +689,7 @@ cbPolicy.Reset(); // Transitions into the Closed state
689
689
690
690
### Circuit breaker in v8
691
691
692
-
> [!TIP]
692
+
> [!NOTE]
693
693
>
694
694
> Polly V8 does not support the standard (*"classic"*) circuit breaker with consecutive failure counting.
695
695
>
@@ -769,23 +769,24 @@ ____
769
769
>
770
770
> For further information please check out the [Circuit Breaker resilience strategy documentation](strategies/circuit-breaker.md).
771
771
772
-
## Migrating other policies
772
+
## Migrating `Polly.Context`
773
773
774
-
Migrating is a process similar to the ones described in the previous sections. Keep in mind that:
774
+
The successor of the `Polly.Context` is the `ResilienceContext`. The major differences:
775
775
776
-
-Strategy configurations (or policies in v7) are now in options. Property names should match the v7 APIs and scenarios.
777
-
-Use `ResiliencePipelineBuilder` or `ResiliencePipelineBuilder<T>` and their respective extensions to add specific strategies.
778
-
-For more details on each strategy, refer to the [resilience strategies](strategies/index.md) documentation.
776
+
-`ResilienceContext` is pooled for enhanced performance and cannot be directly created. Instead, use the `ResilienceContextPool` class to get an instance.
777
+
-`Context` allowed directly custom data attachment, whereas `ResilienceContext` employs the `ResilienceContext.Properties` for the same purpose.
778
+
-In order to set or get a custom data you need to utilize the generic `ResiliencePropertyKey` structure.
779
779
780
-
##Migrating `Polly.Context`
780
+
### Predefined keys
781
781
782
-
`Polly.Context` has been succeeded by `ResilienceContext`. Here are the main changes:
782
+
| In V7 | In V8 |
783
+
| :-- | :-- |
784
+
|`OperationKey`| It can be used in the same way |
785
+
|`PolicyKey`| It's been relocated to `ResiliencePipelineBuilder` and used for [telemetry](advanced/telemetry.md#metrics)|
786
+
|`PolicyWrapKey`| It's been relocated to `ResiliencePipelineBuilder` and used for [telemetry](advanced/telemetry.md#metrics)|
787
+
|`CorrelationId`| It's been removed. For similar functionality, you can either use `System.Diagnostics.Activity.Current.Id` or attach your custom Id using `ResilienceContext.Properties`. |
783
788
784
-
-`ResilienceContext` is pooled for enhanced performance and cannot be directly created. Instead, use the `ResilienceContextPool` class to get an instance.
785
-
- Directly attaching custom data is supported by `Context`, whereas `ResilienceContext` employs the `ResilienceContext.Properties` property.
786
-
- Both `PolicyKey` and `PolicyWrapKey` are no longer a part of `ResilienceContext`. They've been relocated to `ResiliencePipelineBuilder` and are now used for [telemetry](advanced/telemetry.md#metrics).
787
-
- The `CorrelationId` property has been removed. For similar functionality, you can either use `System.Diagnostics.Activity.Current.Id` or attach your custom Id using `ResilienceContext.Properties`.
788
-
- Additionally, `ResilienceContext` introduces the `CancellationToken` property.
789
+
- Additionally, `ResilienceContext` introduces a new property for `CancellationToken`.
789
790
790
791
### `Context` in v7
791
792
@@ -798,12 +799,19 @@ Context context = new Context();
> - Use `ResiliencePipelineRegistry<TResult>` to add or get a pipelines to the registry
1063
+
> - Prefer the safer methods (for example: `TryGetPipeline{<TResult>}`) over their counterpart (for example: `GetPipeline{<TResult>}`)
1064
+
>
1065
+
> For further information please check out the [Resilience pipeline registry documentation](pipelines/resilience-pipeline-registry.md).
1066
+
1014
1067
## Interoperability between policies and resilience pipelines
1015
1068
1016
-
In certain scenarios, you might not want to migrate your code to the v8 API. Instead, you may prefer to use strategies from v8 and apply them to v7 APIs. Polly provides a set of extension methods to support easy conversion from v8 to v7 APIs, as shown in the example below:
1069
+
In certain scenarios, you might not able to migrate all your code to the v8 API.
1070
+
1071
+
In the name of interoperability you can define V8 strategies use them with your v7 policies.
1072
+
1073
+
V8 provides a set of extension methods to support easy conversion from v8 to v7 APIs, as shown in the example below:
1017
1074
1018
1075
> [!NOTE]
1019
1076
> In v8, you have to add the [`Polly.RateLimiting`](https://www.nuget.org/packages/Polly.RateLimiting) package to your application otherwise you won't see the `AddRateLimiter` extension.
0 commit comments