marsevilspirit commented on code in PR #2900:
URL: https://github.com/apache/dubbo-go/pull/2900#discussion_r2114169453


##########
protocol/triple/client.go:
##########
@@ -206,6 +197,13 @@ func newClientManager(url *common.URL) (*clientManager, 
error) {
                tlsFlag = true
        }
 
+       cliKeepAliveOpts, keepAliveInterval, keepAliveTimeout, 
genKeepAliveOptsErr := genKeepAliveOpts(url)
+       if genKeepAliveOptsErr != nil {
+               return nil, genKeepAliveOptsErr

Review Comment:
   fixed.



##########
protocol/triple/client.go:
##########
@@ -282,6 +280,49 @@ func newClientManager(url *common.URL) (*clientManager, 
error) {
        }, nil
 }
 
+func genKeepAliveOpts(url *common.URL) ([]tri.ClientOption, time.Duration, 
time.Duration, error) {
+       var cliKeepAliveOpts []tri.ClientOption
+
+       // set max send and recv msg size
+       maxCallRecvMsgSize := constant.DefaultMaxCallRecvMsgSize
+       if recvMsgSize, err := 
humanize.ParseBytes(url.GetParam(constant.MaxCallRecvMsgSize, "")); err == nil 
&& recvMsgSize > 0 {
+               maxCallRecvMsgSize = int(recvMsgSize)
+       }
+       cliKeepAliveOpts = append(cliKeepAliveOpts, 
tri.WithReadMaxBytes(maxCallRecvMsgSize))
+       maxCallSendMsgSize := constant.DefaultMaxCallSendMsgSize
+       if sendMsgSize, err := 
humanize.ParseBytes(url.GetParam(constant.MaxCallSendMsgSize, "")); err == nil 
&& sendMsgSize > 0 {
+               maxCallSendMsgSize = int(sendMsgSize)
+       }
+       cliKeepAliveOpts = append(cliKeepAliveOpts, 
tri.WithSendMaxBytes(maxCallSendMsgSize))
+
+       // set keepalive interval and keepalive timeout
+       // Deprecated:use tripleconfig
+       // TODO: remove KeepAliveInterval and KeepAliveInterval in version 4.0.0
+       keepAliveInterval := url.GetParamDuration(constant.KeepAliveInterval, 
constant.DefaultKeepAliveInterval)
+       keepAliveTimeout := url.GetParamDuration(constant.KeepAliveTimeout, 
constant.DefaultKeepAliveTimeout)
+
+       tripleConfRaw, ok := url.GetAttribute(constant.TripleConfigKey)
+       if ok {
+               var parseErr error
+               tripleConf := tripleConfRaw.(*global.TripleConfig)
+               // TODO: handle ParseDuration error
+               if tripleConf != nil && tripleConf.KeepAliveInterval != "" {
+                       keepAliveInterval, parseErr = 
time.ParseDuration(tripleConf.KeepAliveInterval)
+                       if parseErr != nil {
+                               return nil, 0, 0, parseErr
+                       }
+               }
+               if tripleConf != nil && tripleConf.KeepAliveTimeout != "" {
+                       keepAliveTimeout, parseErr = 
time.ParseDuration(tripleConf.KeepAliveTimeout)
+                       if parseErr != nil {
+                               return nil, 0, 0, parseErr
+                       }

Review Comment:
   fixed.



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