From 402714bad9bd148c3dbe3010475215dd971f6c52 Mon Sep 17 00:00:00 2001 From: peter-csala Date: Fri, 20 Oct 2023 15:08:29 +0200 Subject: [PATCH] Refactors based on review --- docs/pipelines/index.md | 28 ++++++++++++++++-------- src/Snippets/Docs/ResiliencePipelines.cs | 22 ++++++++++++++----- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/docs/pipelines/index.md b/docs/pipelines/index.md index a6b245c7c76..a885a3f5d09 100644 --- a/docs/pipelines/index.md +++ b/docs/pipelines/index.md @@ -137,10 +137,13 @@ Use `ExecuteOutcomeAsync(...)` in high-performance scenarios where you wish to a ## Diagrams -### Variant one +### Sequence diagram for a pipeline with retry and timeout - + ```cs +// Let's create the following pipeline: +// the inner strategy is a timeout, +// the outer is a retry which is timeout-aware. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddRetry(new() { ShouldHandle = new PredicateBuilder().Handle() }) // outer .AddTimeout(TimeSpan.FromSeconds(1)) // inner @@ -148,7 +151,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder() ``` -Lets suppose that the first request takes too long bust the second is super fast. +Let's suppose that the first request takes too long but the second is fast enough. ```mermaid sequenceDiagram @@ -193,10 +196,13 @@ sequenceDiagram P->>C: Returns result ``` -### Variant two +### Sequence diagram for a pipeline with timeout and retry - + ```cs +// Let's create the following pipeline: +// the inner strategy is a retry, +// the outer is a timeout which overarches all retry attempts. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddTimeout(TimeSpan.FromSeconds(10)) // outer .AddRetry(new()) // inner @@ -204,7 +210,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder() ``` -Lets suppose that the 1st and the 2nd requests are failing. The 3rd requested is not awaited since the overarching timeout elapsed. +Let's suppose that the first and the second requests are failing. The third request is not awaited since the overarching timeout elapsed. ```mermaid sequenceDiagram @@ -253,10 +259,14 @@ sequenceDiagram P->>C: Propagates exception ``` -### Variant three +### Sequence diagram for a pipeline with timeout, retry and timeout - + ```cs +// Let's create the following pipeline: +// the inner most strategy is a timeout (per attempt), +// the middle one is a retry which is timeout-aware, +// the outer most is a timeout which overarches all retry attempts. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddTimeout(TimeSpan.FromSeconds(10)) // outer most .AddRetry(new() { ShouldHandle = new PredicateBuilder().Handle() }) @@ -265,7 +275,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder() ``` -Lets suppose that the 1st request fails; the 2nd requests takes too long; and the 3rd requested is not awaited since the overarching timeout elapsed. +Let's suppose that the first request fails and the second takes too long. The third request is not awaited since the overarching timeout elapsed. ```mermaid sequenceDiagram diff --git a/src/Snippets/Docs/ResiliencePipelines.cs b/src/Snippets/Docs/ResiliencePipelines.cs index ed2a56c8820..e2e6ac0d130 100644 --- a/src/Snippets/Docs/ResiliencePipelines.cs +++ b/src/Snippets/Docs/ResiliencePipelines.cs @@ -83,9 +83,12 @@ public static void ConfigureMyPipelines(IServiceCollection services) #endregion - public static void ResiliencePipelinesDiagramVariantOne() + public static void ResiliencePipelinesDiagramRetryTimeout() { - #region resilience-pipeline-diagram-variant-1 + #region resilience-pipeline-diagram-retry-timeout + // Let's create the following pipeline: + // the inner strategy is a timeout, + // the outer is a retry which is timeout-aware. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddRetry(new() { ShouldHandle = new PredicateBuilder().Handle() }) // outer .AddTimeout(TimeSpan.FromSeconds(1)) // inner @@ -93,9 +96,12 @@ public static void ResiliencePipelinesDiagramVariantOne() #endregion } - public static void ResiliencePipelinesDiagramVariantTwo() + public static void ResiliencePipelinesDiagramTimeoutRetry() { - #region resilience-pipeline-diagram-variant-2 + #region resilience-pipeline-diagram-timeout-retry + // Let's create the following pipeline: + // the inner strategy is a retry, + // the outer is a timeout which overarches all retry attempts. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddTimeout(TimeSpan.FromSeconds(10)) // outer .AddRetry(new()) // inner @@ -103,9 +109,13 @@ public static void ResiliencePipelinesDiagramVariantTwo() #endregion } - public static void ResiliencePipelinesDiagramVariantThree() + public static void ResiliencePipelinesDiagramTimeoutRetryTimeout() { - #region resilience-pipeline-diagram-variant-3 + #region resilience-pipeline-diagram-timeout-retry-timeout + // Let's create the following pipeline: + // the inner most strategy is a timeout (per attempt), + // the middle one is a retry which is timeout-aware, + // the outer most is a timeout which overarches all retry attempts. ResiliencePipeline pipeline = new ResiliencePipelineBuilder() .AddTimeout(TimeSpan.FromSeconds(10)) // outer most .AddRetry(new() { ShouldHandle = new PredicateBuilder().Handle() })