Skip to content

Commit

Permalink
Fix sample (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-csala authored Feb 19, 2024
1 parent 1ce60b2 commit de7fdb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/strategies/fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ var fallback = new ResiliencePipelineBuilder<HttpResponseMessage>()
{
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.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();

Expand Down
6 changes: 3 additions & 3 deletions src/Snippets/Docs/Fallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ private static ValueTask<HttpResponseMessage> ActionCore()
}
#endregion

private static ValueTask<HttpResponseMessage> CallPrimary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage());
private static ValueTask<HttpResponseMessage> CallSecondary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage());
private static ValueTask<HttpResponseMessage> CallPrimary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage(HttpStatusCode.RequestTimeout));
private static ValueTask<HttpResponseMessage> CallSecondary(CancellationToken ct) => ValueTask.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
public static async Task<HttpResponseMessage?> AntiPattern_RetryForFallback()
{
var fallbackKey = new ResiliencePropertyKey<HttpResponseMessage?>("fallback_result");
Expand Down Expand Up @@ -190,7 +190,7 @@ private static ValueTask<HttpResponseMessage> ActionCore()
{
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.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();

Expand Down

0 comments on commit de7fdb0

Please sign in to comment.