Skip to content

Commit

Permalink
[Docs] Small cleanup and improvements (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk committed Nov 10, 2023
1 parent 56890d8 commit 6978c8f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
9 changes: 4 additions & 5 deletions docs/advanced/dependency-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,18 @@ ResiliencePipeline instanceB = pipelineProvider.GetPipeline(new MyPipelineKey("m
```
<!-- endSnippet -->

## Patterns and anti-patterns
## Anti-patterns

Over the years, many developers have used Polly in various ways. Some of these
recurring patterns may not be ideal. This section highlights the recommended practices
and those to avoid.
recurring patterns may not be ideal. The sections below highlight anti-patterns to avoid.

### 1 - Accessing the `IServiceCollection` instead of `IServiceProvider`
### Accessing the `IServiceCollection` instead of `IServiceProvider`

❌ DON'T

Capture `IServiceCollection` inside `AddResiliencePipeline()`:

<!-- snippet: di-anti-pattern-1 -->
<!-- snippet: di-not-using-service-provider -->
```cs
var services = new ServiceCollection();
services.AddResiliencePipeline("myFavoriteStrategy", builder =>
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/resilience-context.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Resilience context

The `ResilienceContext` class in Polly provides an execution-scoped instance that accompanies each execution through a Polly resilience strategy. This class serves to share context and facilitate information exchange between the pre-execution, mid-execution, and post-execution phases.
The `ResilienceContext` class in Polly provides an execution-scoped instance that accompanies each execution through a Polly resilience pipeline and across all strategies in the pipeline. This class serves to share context and facilitate information exchange between the pre-execution, mid-execution, and post-execution phases.

The resilience context exposes several properties:

Expand Down
3 changes: 2 additions & 1 deletion docs/strategies/circuit-breaker.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ sequenceDiagram

## Anti-patterns

Over the years, many developers have used Polly in various ways. Some of these recurring patterns may not be ideal. This section highlights the recommended practices and those to avoid.
Over the years, many developers have used Polly in various ways. Some of these
recurring patterns may not be ideal. The sections below highlight anti-patterns to avoid.

### Using different sleep duration between retry attempts based on Circuit Breaker state

Expand Down
3 changes: 2 additions & 1 deletion docs/strategies/fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ Here's a breakdown of the behavior when the callback produces either an `HttpSta
## Anti-patterns

Over the years, many developers have used Polly in various ways. Some of these recurring patterns may not be ideal. This section highlights the recommended practices and ones to avoid.
Over the years, many developers have used Polly in various ways. Some of these
recurring patterns may not be ideal. The sections below highlight anti-patterns to avoid.

### Using fallback to replace thrown exception

Expand Down
3 changes: 2 additions & 1 deletion docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ while (!cancellationToken.IsCancellationRequested)

## Anti-patterns

Over the years, many developers have used Polly in various ways. Some of these recurring patterns may not be ideal. This section highlights the recommended practices and those to avoid.
Over the years, many developers have used Polly in various ways. Some of these
recurring patterns may not be ideal. The sections below highlight anti-patterns to avoid.

### Overusing builder methods

Expand Down
3 changes: 3 additions & 0 deletions docs/strategies/timeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ sequenceDiagram

## Anti-patterns

Over the years, many developers have used Polly in various ways. Some of these
recurring patterns may not be ideal. The sections below highlight anti-patterns to avoid.

### Ignoring Cancellation Token

❌ DON'T
Expand Down
4 changes: 3 additions & 1 deletion src/Snippets/Docs/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public static async Task ConfigureRegistry(IServiceProvider serviceProvider)

public static void AntiPattern_1()
{
#region di-anti-pattern-1
#region di-not-using-service-provider

var services = new ServiceCollection();
services.AddResiliencePipeline("myFavoriteStrategy", builder =>
{
Expand All @@ -207,6 +208,7 @@ public static void AntiPattern_1()
}
});
});

#endregion
}

Expand Down

0 comments on commit 6978c8f

Please sign in to comment.