结合上一篇文章我写了一个demo测试下
重试2次
_polly.PollyRetry<Exception>(()=>_demoQuery.GetTestAOPAsync(), 2);
结果:
按需重试
_polly.PollyWaitAndRetry<Exception>(() => _demoQuery.GetTestAOPAsync(), new TimeSpan[]{ TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(9), TimeSpan.FromSeconds(18) });
结果:
熔断
_polly.PollyCircuitBreaker<Exception>(() => _demoQuery.GetTestAOPAsync(), 4, TimeSpan.FromSeconds(10));
结果