Skip to content

Commit

Permalink
Minor fixes on pipeline registry
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-csala authored and martincostello committed Oct 27, 2023
1 parent 9b2b170 commit c62ab82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions docs/pipelines/resilience-pipeline-registry.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Resilience pipeline registry

> [!NOTE]
> This documentation supports the upcoming Polly v8 release.
The `ResiliencePipelineRegistry<TKey>` is designed to create and cache resilience pipeline instances. The registry also implements the `ResiliencePipelineProvider<TKey>`, allowing read-only access to pipelines.

The registry offers these features:
Expand All @@ -19,6 +16,9 @@ The registry offers these features:

To register pipeline builders, use the `TryAddBuilder(...)` method. This method accepts a callback argument that configures an instance of `ResiliencePipelineBuilder` for the pipeline being defined. The registry supports both generic and non-generic resilience pipelines.

> [!NOTE]
> Please note that you do not have to call the `Build` method after you have set up your pipeline on the `builder` parameter of the `TryAddBuilder`. You can call the `Build` if you want but it is not necessary.
Here's an example demonstrating these features:

<!-- snippet: registry-usage -->
Expand Down Expand Up @@ -47,7 +47,7 @@ ResiliencePipeline pipelineA = registry.GetPipeline("A");
ResiliencePipeline<HttpResponseMessage> genericPipelineA = registry.GetPipeline<HttpResponseMessage>("A");

// Returns false since pipeline "unknown" isn't registered
registry.TryGetPipeline("unknown", out var pipeline);
var doesPipelineExist = registry.TryGetPipeline("unknown", out var pipeline);

// Throws KeyNotFoundException because pipeline "unknown" isn't registered
try
Expand Down Expand Up @@ -108,8 +108,8 @@ var options = new ResiliencePipelineRegistryOptions<string>
PipelineComparer = StringComparer.OrdinalIgnoreCase,
BuilderFactory = () => new ResiliencePipelineBuilder
{
InstanceName = "lets change the defaults",
Name = "lets change the defaults",
InstanceName = "lets change the default of InstanceName",
Name = "lets change the default of Name",
},
BuilderNameFormatter = key => $"key:{key}",
InstanceNameFormatter = key => $"instance-key:{key}",
Expand Down Expand Up @@ -144,7 +144,7 @@ ResiliencePipeline pipeline = registry.GetPipeline("A");
<!-- endSnippet -->

- If an error occurs during reloading, the cached pipeline remains, and dynamic reloading stops.
- You should not reuse the cancellation token when the pipeline is reloaded.
- You should **not** reuse the cancellation token when the pipeline is reloaded.
- Pipelines enabled for reloads remain valid and current post-reload. The registry manages this transparently.

### How dynamic reloads work
Expand Down
6 changes: 3 additions & 3 deletions src/Snippets/Docs/ResiliencePipelineRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static async Task Usage()
ResiliencePipeline<HttpResponseMessage> genericPipelineA = registry.GetPipeline<HttpResponseMessage>("A");

// Returns false since pipeline "unknown" isn't registered
registry.TryGetPipeline("unknown", out var pipeline);
var doesPipelineExist = registry.TryGetPipeline("unknown", out var pipeline);

// Throws KeyNotFoundException because pipeline "unknown" isn't registered
try
Expand Down Expand Up @@ -82,8 +82,8 @@ public static async Task RegistryOptions()
PipelineComparer = StringComparer.OrdinalIgnoreCase,
BuilderFactory = () => new ResiliencePipelineBuilder
{
InstanceName = "lets change the defaults",
Name = "lets change the defaults",
InstanceName = "lets change the default of InstanceName",
Name = "lets change the default of Name",
},
BuilderNameFormatter = key => $"key:{key}",
InstanceNameFormatter = key => $"instance-key:{key}",
Expand Down

0 comments on commit c62ab82

Please sign in to comment.