Skip to content

Commit

Permalink
Post dotnet mdsnippets run
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Sep 21, 2023
1 parent c17f3f2 commit bfe49e4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README_V8.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
.Build(); // Builds the resilience pipeline
// Execute the pipeline asynchronously
await pipeline.ExecuteAsync(async cancellationToken => { /*Your custom logic here */ }, cancellationToken);
await pipeline.ExecuteAsync(static async cancellationToken => { /*Your custom logic here */ }, cancellationToken);
```
<!-- endSnippet -->

Expand Down Expand Up @@ -84,7 +84,7 @@ var pipelineProvider = serviceProvider.GetRequiredService<ResiliencePipelineProv
ResiliencePipeline pipeline = pipelineProvider.GetPipeline("my-pipeline");

// Execute the pipeline
await pipeline.ExecuteAsync(async token =>
await pipeline.ExecuteAsync(static async token =>
{
// Your custom logic here
});
Expand Down
3 changes: 2 additions & 1 deletion docs/advanced/dependency-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ ResiliencePipelineProvider<string> pipelineProvider = serviceProvider.GetRequire
ResiliencePipeline pipeline = pipelineProvider.GetPipeline("my-key");

// Use it
await pipeline.ExecuteAsync(async cancellation => await Task.Delay(100, cancellation));
await pipeline.ExecuteAsync(
static async cancellation => await Task.Delay(100, cancellation));
```
<!-- endSnippet -->

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/resilience-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder()

// Execute the resilience pipeline asynchronously
await pipeline.ExecuteAsync(
async context =>
static async context =>
{
// Insert your execution logic here
},
Expand Down
2 changes: 1 addition & 1 deletion docs/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ await pipeline.ExecuteAsync(
ResilienceContext context = ResilienceContextPool.Shared.Get(cancellationToken: cancellationToken);

await pipeline.ExecuteAsync(
async context => await MyMethodAsync(context.CancellationToken),
static async context => await MyMethodAsync(context.CancellationToken),
context);
```
<!-- endSnippet -->
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
.Build(); // Builds the resilience pipeline
// Execute the pipeline asynchronously
await pipeline.ExecuteAsync(async cancellationToken => { /*Your custom logic here */ }, cancellationToken);
await pipeline.ExecuteAsync(static async cancellationToken => { /*Your custom logic here */ }, cancellationToken);
```
<!-- endSnippet -->

Expand Down Expand Up @@ -55,7 +55,7 @@ var pipelineProvider = serviceProvider.GetRequiredService<ResiliencePipelineProv
ResiliencePipeline pipeline = pipelineProvider.GetPipeline("my-pipeline");

// Execute the pipeline
await pipeline.ExecuteAsync(async token =>
await pipeline.ExecuteAsync(static async token =>
{
// Your custom logic here
});
Expand Down
4 changes: 2 additions & 2 deletions docs/migration-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pipeline.Execute(() =>
});

// Asynchronous execution is also supported with the same pipeline instance
await pipeline.ExecuteAsync(async cancellationToken =>
await pipeline.ExecuteAsync(static async cancellationToken =>
{
// your code here
},
Expand Down Expand Up @@ -135,7 +135,7 @@ pipelineT.Execute(() =>
});

// Asynchronous execution
await pipelineT.ExecuteAsync(async cancellationToken =>
await pipelineT.ExecuteAsync(static async cancellationToken =>
{
// your code here
return await GetResponseAsync(cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion docs/strategies/fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Nest `ExecuteAsync` calls
```cs
var result = await fallback.ExecuteAsync(async (CancellationToken outerCT) =>
{
return await timeout.ExecuteAsync(async (CancellationToken innerCT) =>
return await timeout.ExecuteAsync(static async (CancellationToken innerCT) =>
{
return await CallExternalSystem(innerCT);
}, outerCT);
Expand Down
6 changes: 3 additions & 3 deletions docs/strategies/hedging.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ internal class HedgingHandler : DelegatingHandler

try
{
return await _pipeline.ExecuteAsync(async context =>
return await _pipeline.ExecuteAsync(async cxt =>
{
// Allow the pipeline to use request message that was stored in the context.
// This allows replacing the request message with a new one in the resilience pipeline.
request = context.Properties.GetValue(ResilienceKeys.RequestMessage, request);
request = cxt.Properties.GetValue(ResilienceKeys.RequestMessage, request);

return await base.SendAsync(request, context.CancellationToken);
return await base.SendAsync(request, cxt.CancellationToken);
},
context);
}
Expand Down
10 changes: 7 additions & 3 deletions docs/strategies/retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,12 @@ var builder = new ResiliencePipelineBuilder()
builder.AddTimeout(TimeSpan.FromMinutes(1));

var pipeline = builder.Build();
await pipeline.ExecuteAsync(async (ct) =>
await pipeline.ExecuteAsync(static async (httpClient, ct) =>
{
var stream = await httpClient.GetStreamAsync(new Uri("endpoint"), ct);
var foo = await JsonSerializer.DeserializeAsync<Foo>(stream, cancellationToken: ct);
});
},
httpClient);
```
<!-- endSnippet -->

Expand All @@ -409,7 +410,10 @@ var retry = new ResiliencePipelineBuilder()
})
.Build();

var stream = await retry.ExecuteAsync(async (ct) => await httpClient.GetStreamAsync(new Uri("endpoint"), ct));
var stream = await retry.ExecuteAsync(
static async (httpClient, ct) =>
await httpClient.GetStreamAsync(new Uri("endpoint"), ct),
httpClient);

var timeout = new ResiliencePipelineBuilder<Foo>()
.AddTimeout(TimeSpan.FromMinutes(1))
Expand Down

0 comments on commit bfe49e4

Please sign in to comment.