Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Minor fixes on pipeline registry #1733

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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