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
[Docs] Add minor tweaks to migration guide 1/3 (#1763)
* Revise Policies, Retry
* Add tldr and links at end of each section
* Add tldr and links at end of each section
* Add missing static keywords
* Review extra empty lines
* Fix linting
* Apply suggestions from code review
In v8, there's no need to use policy wrap explicitly. Instead, policy wrapping is integrated into `ResiliencePipelineBuilder`, as shown in the example below:
176
+
In v8, there's no need to use policy wrap explicitly. Instead, policy wrapping is integrated into `ResiliencePipelineBuilder`:
169
177
170
178
<!-- snippet: migration-policy-wrap-v8 -->
171
179
```cs
@@ -185,12 +193,20 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
185
193
```
186
194
<!-- endSnippet -->
187
195
188
-
> [!NOTE]
189
-
> See [fallback after retries](strategies/fallback.md#fallback-after-retries) for an example on how the strategies are executed.
196
+
See [fallback after retries](strategies/fallback.md#fallback-after-retries) for an example on how the strategies are executed.
197
+
198
+
> [!IMPORTANT]
199
+
>
200
+
> Things to remember:
201
+
>
202
+
> - Use `ResiliencePipelineBuilder{<TResult>}` to build a resiliency pipeline
203
+
> - Use multiple `Add*` builder methods to add new strategies to your pipeline
204
+
>
205
+
> For further information please check out the [Resilience pipelines documentation](pipelines/index.md).
190
206
191
207
## Migrating retry policies
192
208
193
-
This section describes how to migrate the v7 retry policy to a resilience strategy in v8.
209
+
This section describes how to migrate v7 retry policies to V8 retry strategies.
194
210
195
211
### Retry in v7
196
212
@@ -200,13 +216,13 @@ In v7 the retry policy is configured as:
200
216
```cs
201
217
// Retry once
202
218
Policy
203
-
.Handle<SomeExceptionType>()
204
-
.Retry();
219
+
.Handle<SomeExceptionType>()
220
+
.Retry();
205
221
206
222
// Retry multiple times
207
223
Policy
208
-
.Handle<SomeExceptionType>()
209
-
.Retry(3);
224
+
.Handle<SomeExceptionType>()
225
+
.Retry(3);
210
226
211
227
// Retry multiple times with callback
212
228
Policy
@@ -215,6 +231,11 @@ Policy
215
231
{
216
232
// Add logic to be executed before each retry, such as logging
217
233
});
234
+
235
+
// Retry forever
236
+
Policy
237
+
.Handle<SomeExceptionType>()
238
+
.RetryForever();
218
239
```
219
240
<!-- endSnippet -->
220
241
@@ -254,7 +275,7 @@ new ResiliencePipelineBuilder().AddRetry(new RetryStrategyOptions
@@ -388,7 +404,14 @@ new ResiliencePipelineBuilder<HttpResponseMessage>().AddRetry(new RetryStrategyO
388
404
```
389
405
<!-- endSnippet -->
390
406
391
-
It's important to remember that the configuration in v8 is options based, i.e. `RetryStrategyOptions` are used.
407
+
> [!IMPORTANT]
408
+
>
409
+
> Things to remember:
410
+
>
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
413
+
>
414
+
> For further information please check out the [Retry resilience strategy documentation](strategies/retry.md).
392
415
393
416
## Migrating rate limit policies
394
417
@@ -452,6 +475,15 @@ ResiliencePipeline<HttpResponseMessage> pipelineT = new ResiliencePipelineBuilde
452
475
```
453
476
<!-- endSnippet -->
454
477
478
+
> [!IMPORTANT]
479
+
>
480
+
> Things to remember:
481
+
>
482
+
> - Use `AddRateLimiter` to add a rate limiter strategy to your resiliency pipeline
483
+
> - Use one of the derived classes of [`ReplenishingRateLimiter`](https://learn.microsoft.com/dotnet/api/system.threading.ratelimiting.replenishingratelimiter) to customize your rate limiter behavior to meet your requirements
484
+
>
485
+
> For further information please check out the [Rate limiter resilience strategy documentation](strategies/rate-limiter.md).
486
+
455
487
## Migrating bulkhead policies
456
488
457
489
The bulkhead policy is now replaced by the [rate limiter strategy](strategies/rate-limiter.md) which uses the [`System.Threading.RateLimiting`](https://www.nuget.org/packages/System.Threading.RateLimiting) package. The new counterpart to bulkhead is `ConcurrencyLimiter`.
@@ -464,16 +496,24 @@ The bulkhead policy is now replaced by the [rate limiter strategy](strategies/ra
0 commit comments