microservices - 当出现 n 个异常时,Ocelot QoS 不会断路
问题描述
我正在Ocelot Gateway上执行 PoC以用于我们的微服务架构。到目前为止,我已成功使用网关执行所有路由任务。
它提供了一个 QoS 服务,该服务在 ocelot.json 中为断路器保存配置,并在一段时间内断开电路。
我的ocelot.json文件中针对特定路由设置的配置如下:
{
"DownstreamPathTemplate": "/api/classes/exception/{id}",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/classes/exception/{id}",
"ServiceName": "class-service",
"UpstreamHttpMethod": [ "Get" ],
"LoadBalancerOptions": {
"Type": "LeastConnection"
},
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 2,
"DurationOfBreak": 10000,
"TimeoutValue": 3000
}
}
现在,这适用于超时问题,当路由在 3 秒内没有响应时,它会中断电路 10 秒。
但是对于异常情况,在调用路由时,出现2次异常时,不会断路。
是否需要更多配置?
我为 Ocelot 和 Ocelot.Provider.Polly 添加了 Nuget 包,并在我的Startup.cs文件中添加了以下内容:
s.AddOcelot().AddPolly();
请帮我解决这个问题。我已经按照 [Ocelot 文档] https://ocelot.readthedocs.io/en/latest/features/qualityofservice.html来实现这个
解决方案
推荐阅读
- javascript - 禁用按钮并在行上显示沙漏(htmx)
- c# - DateTimePicker c# 仅适用于月份
- python - 将多个外生变量传递给 ARMA
- mysql - 无法注册新用户 vue/express/mysql
- sql - 休眠慢sql未记录
- javascript - 处理来自 servlet 的 AJAX 响应
- nginx - 如何使用 NGINX 代理 RTMP
- android - 无法在 Android Stuio 的 activity_main.xml 文件中编辑或写入任何内容
- reactjs - 更新 Redux 中的旧值和新值
- jquery - 根据所选日期填充下拉列表