Skip to content

Commit

Permalink
Unify timeout unit to millisecond in dubbo protocol (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Oct 14, 2024
1 parent a6cf7ae commit d1fe72b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
TokenKey = "token"
LocalAddr = "local-addr"
RemoteAddr = "remote-addr"
DefaultRemotingTimeout = 3000
DefaultRemotingTimeout = 1000
ReleaseKey = "release"
AnyhostKey = "anyhost"
PortKey = "port"
Expand Down
14 changes: 7 additions & 7 deletions protocol/dubbo/dubbo_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package dubbo

import (
"bytes"
"strconv"
"time"
)

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion protocol/dubbo/dubbo_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d1fe72b

Please sign in to comment.