我指的是这个 https://github.com/Pathoschild/FluentHttpClient#custom-retry--coordination来创建自定义重试协调并尝试在此处使用 Polly,但我遇到了以下错误,
“PolicyBuilder<HttpResponseMessage>”不包含“重试”的定义,并且最佳扩展方法重载“RetrySyntax.Retry(PolicyBuilder, int, Action)”需要“PolicyBuilder”类型的接收器
这里有什么问题?
public class PollyCoordinator : IRequestCoordinator
{
public Task<HttpResponseMessage> ExecuteAsync(IRequest request, Func<IRequest, Task<HttpResponseMessage>> dispatcher)
{
int[] retryCodes = { 408, 500, 502, 503, 504 };
return Policy
.HandleResult<HttpResponseMessage>(r => retryCodes.Contains((int)r.StatusCode))
.Retry(3, async () => await dispatcher(request));
}
}