You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
namespace Polly8Study.Test
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Polly8<79><38>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
/// <20>ؼ<EFBFBD><D8BC><EFBFBD>
|
|
|
|
|
/// CancellationToken<65><6E>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>֮ǰ<D6AE>汾<EFBFBD>е<EFBFBD><D0B5>ֹ۳<D6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>۳<EFBFBD>ʱò<CAB1><C3B2>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Polly8RetryStrategyTest
|
|
|
|
|
{
|
|
|
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
|
|
|
|
|
|
public Polly8RetryStrategyTest(ITestOutputHelper testOutput)
|
|
|
|
|
{
|
|
|
|
|
_output = testOutput;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Test()
|
|
|
|
|
{
|
|
|
|
|
ResiliencePipeline pipeline = new ResiliencePipelineBuilder()
|
|
|
|
|
.AddRetry(new RetryStrategyOptions
|
|
|
|
|
{
|
|
|
|
|
ShouldHandle = new Polly.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.
|
|
|
|
|
|
|
|
|
|
// Synchronous execution
|
|
|
|
|
pipeline.Execute(static () =>
|
|
|
|
|
{
|
|
|
|
|
// Your code goes here
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|