nanjiek commented on code in PR #877:
URL: https://github.com/apache/dubbo-go-pixiu/pull/877#discussion_r2868994988
##########
admin/logic/logic.go:
##########
@@ -51,13 +58,26 @@ const (
Plugin = "plugin"
Filter = "filter"
Ratelimit = "ratelimit"
+ OPA = "opa"
Clusters = "clusters"
Listeners = "listeners"
Unpublished = "unpublished"
ErrID = -1
)
+// Use a shared client to enable HTTP keep-alive and prevent connection
exhaustion
+var opaHTTPClient = &http.Client{
+ Timeout: getOPATimeout(),
+}
+
+func getOPATimeout() time.Duration {
+ if adminconfig.Bootstrap != nil &&
adminconfig.Bootstrap.OPA.RequestTimeout > 0 {
+ return adminconfig.Bootstrap.OPA.RequestTimeout
+ }
+ return adminconfig.DefaultOPAPolicyTimeout
+}
Review Comment:
做出以下修改1. 将 OPA 请求超时限制逻辑迁移至每个请求的 context.WithTimeout 中,确保 opa.request_timeout
配置项在配置加载完成后能够生效。
2. 保留了共享的 opaHTTPClient 实例,以维持连接保活(keep-alive)/连接池机制。
3. 新增了兜底的客户端超时机制(当前设置为 30 秒),作为最后的防护措施。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]