Similarityoung commented on code in PR #877:
URL: https://github.com/apache/dubbo-go-pixiu/pull/877#discussion_r2839459066


##########
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:
   opaHTTPClient 在包加载时就初始化了,adminconfig.Bootstrap 当时还没加载,所以 opa.request_timeout 
配置不会生效,实际一直走默认 8s。
   



-- 
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]

Reply via email to