This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/main by this push:
     new d1fe72b70 Unify timeout unit to millisecond in dubbo protocol (#2737)
d1fe72b70 is described below

commit d1fe72b705c749a8b4b7725909ac06e333551cb5
Author: Albumen Kevin <[email protected]>
AuthorDate: Mon Oct 14 14:24:10 2024 +0800

    Unify timeout unit to millisecond in dubbo protocol (#2737)
---
 common/constant/key.go          |  2 +-
 protocol/dubbo/dubbo_codec.go   | 14 +++++++-------
 protocol/dubbo/dubbo_invoker.go |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/common/constant/key.go b/common/constant/key.go
index 7164b1250..805949a6a 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -47,7 +47,7 @@ const (
        TokenKey               = "token"
        LocalAddr              = "local-addr"
        RemoteAddr             = "remote-addr"
-       DefaultRemotingTimeout = 3000
+       DefaultRemotingTimeout = 1000
        ReleaseKey             = "release"
        AnyhostKey             = "anyhost"
        PortKey                = "port"
diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go
index ec7cbfd80..a78033697 100644
--- a/protocol/dubbo/dubbo_codec.go
+++ b/protocol/dubbo/dubbo_codec.go
@@ -19,6 +19,7 @@ package dubbo
 
 import (
        "bytes"
+       "strconv"
        "time"
 )
 
@@ -69,13 +70,12 @@ func (c *DubboCodec) EncodeRequest(request 
*remoting.Request) (*bytes.Buffer, er
        svc.Version = 
invocation.GetAttachmentWithDefaultValue(constant.VersionKey, "")
        svc.Group = invocation.GetAttachmentWithDefaultValue(constant.GroupKey, 
"")
        svc.Method = invocation.MethodName()
-       //timeout, err := 
strconv.Atoi(invocation.GetAttachmentWithDefaultValue(constant.TimeoutKey, 
strconv.Itoa(constant.DefaultRemotingTimeout)))
-       timeout := 300000
-       //if err != nil {
-       //      // it will be wrapped in readwrite.Write .
-       //      return nil, perrors.WithStack(err)
-       //}
-       svc.Timeout = time.Duration(timeout)
+       timeout, err := 
strconv.Atoi(invocation.GetAttachmentWithDefaultValue(constant.TimeoutKey, 
strconv.Itoa(constant.DefaultRemotingTimeout)))
+       if err != nil {
+               // it will be wrapped in readwrite.Write .
+               return nil, perrors.WithStack(err)
+       }
+       svc.Timeout = time.Duration(timeout) * time.Millisecond
 
        header := impl.DubboHeader{}
        serialization := 
invocation.GetAttachmentWithDefaultValue(constant.SerializationKey, 
constant.Hessian2Serialization)
diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go
index 4daa2d6b7..378deb607 100644
--- a/protocol/dubbo/dubbo_invoker.go
+++ b/protocol/dubbo/dubbo_invoker.go
@@ -177,7 +177,7 @@ func (di *DubboInvoker) getTimeout(ivc 
*invocation.RPCInvocation) time.Duration
                }
        }
        // set timeout into invocation
-       ivc.SetAttachment(constant.TimeoutKey, 
strconv.Itoa(int(timeout.Nanoseconds())))
+       ivc.SetAttachment(constant.TimeoutKey, 
strconv.Itoa(int(timeout.Milliseconds())))
        return timeout
 }
 

Reply via email to