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] Fix antipattern sample code #1976

Merged
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
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