Ocelot
Ocelot copied to clipboard
Use Polly v8 syntax
Use Polly 8's specific syntax to define resiliencePipelines (vs. PollyPolicies)
"Polly v8 introduces the concept of resilience pipelines, a powerful tool that blends one or more resilience strategies. This new API foundation echoes the Policy Wrap of previous versions but is now integrated seamlessly into the core API. All strategies start with a pipeline."
in v7, we written
// Create and use the IAsyncPolicy
IAsyncPolicy asyncPolicy = Policy
.Handle<Exception>()
.WaitAndRetryAsync(3, _ => TimeSpan.FromSeconds(1));
in v8, it becomes
// Use the ResiliencePipelineBuilder to start building the resilience pipeline
ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
.AddRetry(new RetryStrategyOptions
{
ShouldHandle = new PredicateBuilder().Handle<Exception>(),
Delay = TimeSpan.FromSeconds(1),
MaxRetryAttempts = 3,
BackoffType = DelayBackoffType.Constant
})
.Build(); // After all necessary strategies are added, call Build() to create the pipeline.
Wow! Good to know about new Polly 8 features... I see you are big fan of Polly 😉
You need to choose release number: Annual (aka 24.0) or Jan'24 (aka 24.1) We can include this upgrade even in Annual'23: I see the feature branch, seems you're going to create a PR soon... Finally you need to choose release number to include this feature in. OK?
In 24.1