public async Task Invoke(MiddlewareContext context) { var _retryAsync = Policy .Handle <Exception>() .RetryAsync(_options.RetryTimes, async(exception, retryCount) => { await InnerLogger.LogAsync(LoggerLevel.Error, $"-------第{retryCount}次重试!exception:{exception.Message}"); }); // todo:这里设置没有用,还不知道原因; var _timeoutAsync = Policy .TimeoutAsync(TimeSpan.FromMilliseconds(_options.TimoutMilliseconds), async(ct, ts, tk, exception) => { await InnerLogger.LogAsync(LoggerLevel.Error, $"---------超时."); }); await Policy.WrapAsync(_retryAsync, _timeoutAsync).ExecuteAsync(async() => { await _next(context); }); }