From e41f1540e75849830cc2f1be257cd02220a9f14a Mon Sep 17 00:00:00 2001 From: peter-csala Date: Fri, 27 Oct 2023 10:11:56 +0200 Subject: [PATCH] Minor fixes on pipeline registry --- docs/pipelines/resilience-pipeline-registry.md | 14 +++++++------- src/Snippets/Docs/ResiliencePipelineRegistry.cs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pipelines/resilience-pipeline-registry.md b/docs/pipelines/resilience-pipeline-registry.md index e8057e2ac2..b17380676d 100644 --- a/docs/pipelines/resilience-pipeline-registry.md +++ b/docs/pipelines/resilience-pipeline-registry.md @@ -1,8 +1,5 @@ # Resilience pipeline registry -> [!NOTE] -> This documentation supports the upcoming Polly v8 release. - The `ResiliencePipelineRegistry` is designed to create and cache resilience pipeline instances. The registry also implements the `ResiliencePipelineProvider`, allowing read-only access to pipelines. The registry offers these features: @@ -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: @@ -47,7 +47,7 @@ ResiliencePipeline pipelineA = registry.GetPipeline("A"); ResiliencePipeline genericPipelineA = registry.GetPipeline("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 @@ -108,8 +108,8 @@ var options = new ResiliencePipelineRegistryOptions 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}", @@ -144,7 +144,7 @@ ResiliencePipeline pipeline = registry.GetPipeline("A"); - 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 diff --git a/src/Snippets/Docs/ResiliencePipelineRegistry.cs b/src/Snippets/Docs/ResiliencePipelineRegistry.cs index 384121648d..c908e8d92f 100644 --- a/src/Snippets/Docs/ResiliencePipelineRegistry.cs +++ b/src/Snippets/Docs/ResiliencePipelineRegistry.cs @@ -34,7 +34,7 @@ public static async Task Usage() ResiliencePipeline genericPipelineA = registry.GetPipeline("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 @@ -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}",