From 47b60116942543bd3b95468c8b544e465480de4a Mon Sep 17 00:00:00 2001 From: peter-csala Date: Mon, 19 Feb 2024 14:51:36 +0100 Subject: [PATCH] Fix sample --- docs/strategies/fallback.md | 2 +- src/Snippets/Docs/Fallback.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/strategies/fallback.md b/docs/strategies/fallback.md index 2732d807e04..61b7eb18196 100644 --- a/docs/strategies/fallback.md +++ b/docs/strategies/fallback.md @@ -283,7 +283,7 @@ var fallback = new ResiliencePipelineBuilder() { ShouldHandle = new PredicateBuilder() .HandleResult(res => res.StatusCode == HttpStatusCode.RequestTimeout), - OnFallback = async args => await CallSecondary(args.Context.CancellationToken) + FallbackAction = async args => Outcome.FromResult(await CallSecondary(args.Context.CancellationToken)) }) .Build(); diff --git a/src/Snippets/Docs/Fallback.cs b/src/Snippets/Docs/Fallback.cs index cc380638a6f..2699a8da426 100644 --- a/src/Snippets/Docs/Fallback.cs +++ b/src/Snippets/Docs/Fallback.cs @@ -141,8 +141,8 @@ private static ValueTask ActionCore() } #endregion - private static ValueTask CallPrimary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage()); - private static ValueTask CallSecondary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage()); + private static ValueTask CallPrimary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage(HttpStatusCode.RequestTimeout)); + private static ValueTask CallSecondary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage(HttpStatusCode.OK)); public static async Task AntiPattern_RetryForFallback() { var fallbackKey = new ResiliencePropertyKey("fallback_result"); @@ -190,7 +190,7 @@ private static ValueTask ActionCore() { ShouldHandle = new PredicateBuilder() .HandleResult(res => res.StatusCode == HttpStatusCode.RequestTimeout), - OnFallback = async args => await CallSecondary(args.Context.CancellationToken) + FallbackAction = async args => Outcome.FromResult(await CallSecondary(args.Context.CancellationToken)) }) .Build();