I have an application where we communicate with hundreds of HTTPs endpoints.
(我有一个与数百个HTTP端点进行通信的应用程序。)
The application is a proxy of sorts. (该应用程序是各种代理。)
When testing with polly, I've noticed that if one endpoint, say "api.endpoint1.com" fails, the calls to "api.endpoint2.com" and "api.endpoint3.com" will also be in an open/blocked state. (在使用polly进行测试时,我注意到如果一个端点(例如“ api.endpoint1.com”)失败,则对“ api.endpoint2.com”和“ api.endpoint3.com”的调用也将处于打开/阻止状态州。)
This makes sense as I've only defined one policy, but what is the recommended approach to handling this scenario so that calls to unrelated endpoints are not blocked due to another having performance issues? (这很有意义,因为我仅定义了一个策略,但是建议使用什么方法来处理这种情况,以防止由于另一个存在性能问题而阻止对不相关端点的调用?)
Do I create a collection of Policy's, one for each endpoint or is there a way to supply a context key of sorts(ie the hostname) to scope the failures to a given host endpoint?
(我是否创建策略集合,每个端点一个,还是有办法提供某种上下文密钥(即主机名)来将故障范围限定在给定的主机端点上?)
I've reviewed Polly's docs regarding context keys and it appears these are a way to exchange data back and forth and not what I'm looking for here.
(我查看了Polly关于上下文密钥的文档 ,看来这些是来回交换数据的方法,而不是我在这里寻找的内容。)
var policy = Policy
.Handle<TimeoutException>()
.CircuitBreaker(1, TimeSpan.FromSeconds(1));
//dynamic, large list of endpoints.
var m = new HttpRequestMessage(HttpMethod.Post, "https://api.endpoint1.com")
{
Content = new StringContent("some JSON data here", Encoding.UTF8,"application/json")
};
policy.Execute(() => HTTPClientWrapper.PostAsync(message));
ask by user3783214 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…