This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/3.0 by this push:
new ef53b9b83 fix timeout don't support ms bug (#2105)
ef53b9b83 is described below
commit ef53b9b83e7b91d017fc2334c38eb0043129d9d0
Author: FengZhang <[email protected]>
AuthorDate: Sat Nov 5 10:50:35 2022 +0800
fix timeout don't support ms bug (#2105)
---
go.mod | 2 +-
go.sum | 6 ++++--
protocol/dubbo3/dubbo3_invoker.go | 2 +-
protocol/dubbo3/dubbo3_invoker_test.go | 32 ++++++++++++++++++++++++++++++++
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/go.mod b/go.mod
index f6155369d..6eefbaab7 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5
github.com/dubbogo/gost v1.12.6-0.20220824084206-300e27e9e524
github.com/dubbogo/grpc-go v1.42.10
- github.com/dubbogo/triple v1.1.9
+ github.com/dubbogo/triple v1.2.0
github.com/emicklei/go-restful/v3 v3.8.0
github.com/envoyproxy/go-control-plane
v0.10.2-0.20220325020618-49ff273808a1
github.com/fsnotify/fsnotify v1.6.0
diff --git a/go.sum b/go.sum
index bba4706f5..505ac6431 100644
--- a/go.sum
+++ b/go.sum
@@ -180,8 +180,10 @@ github.com/dubbogo/grpc-go v1.42.10/go.mod
h1:JMkPt1mIHL96GAFeYsMoMjew6f1ROKycik
github.com/dubbogo/jsonparser v1.0.1/go.mod
h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
github.com/dubbogo/net v0.0.4/go.mod
h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc=
github.com/dubbogo/triple v1.0.9/go.mod
h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
-github.com/dubbogo/triple v1.1.9
h1:U3ZDh9tyeitp/arSB5qR4wFnbK8MMYm/F4kzn6JokaA=
-github.com/dubbogo/triple v1.1.9/go.mod
h1:9pgEahtmsY/avYJp3dzUQE8CMMVe1NtGBmUhfICKLJk=
+github.com/dubbogo/triple v1.1.8
h1:yE+J3W1NTZCEPa1FoX+VWZH6UF1c0+A2MGfERlU2zbI=
+github.com/dubbogo/triple v1.1.8/go.mod
h1:9pgEahtmsY/avYJp3dzUQE8CMMVe1NtGBmUhfICKLJk=
+github.com/dubbogo/triple v1.2.0
h1:GN75OEAS2WSp/s+sO1FYbQI7F9+U1qQTgIEaCv9gCLQ=
+github.com/dubbogo/triple v1.2.0/go.mod
h1:9pgEahtmsY/avYJp3dzUQE8CMMVe1NtGBmUhfICKLJk=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod
h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0
h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod
h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
diff --git a/protocol/dubbo3/dubbo3_invoker.go
b/protocol/dubbo3/dubbo3_invoker.go
index 11cf801da..955f50190 100644
--- a/protocol/dubbo3/dubbo3_invoker.go
+++ b/protocol/dubbo3/dubbo3_invoker.go
@@ -77,7 +77,7 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
triCodecType := tripleConstant.CodecType(dubboSerializerType)
// new triple client
opts := []triConfig.OptionFunction{
- triConfig.WithClientTimeout(uint32(timeout.Seconds())),
+ triConfig.WithClientTimeout(timeout),
triConfig.WithCodecType(triCodecType),
triConfig.WithLocation(url.Location),
triConfig.WithHeaderAppVersion(url.GetParam(constant.AppVersionKey, "")),
diff --git a/protocol/dubbo3/dubbo3_invoker_test.go
b/protocol/dubbo3/dubbo3_invoker_test.go
index b39af5ba8..05dad0851 100644
--- a/protocol/dubbo3/dubbo3_invoker_test.go
+++ b/protocol/dubbo3/dubbo3_invoker_test.go
@@ -64,3 +64,35 @@ func TestInvoke(t *testing.T) {
assert.NotNil(t, res.Result())
assert.Equal(t, "Hello request name", bizReply.Message)
}
+
+func TestInvokeTimoutConfig(t *testing.T) {
+ go internal.InitDubboServer()
+ time.Sleep(time.Second * 3)
+
+ // test for millisecond
+ tmpMockUrl := mockDubbo3CommonUrl2 + "&timeout=300ms"
+ url, err := common.NewURL(tmpMockUrl)
+ assert.Nil(t, err)
+
+ invoker, err := NewDubboInvoker(url)
+ assert.Nil(t, err)
+
+ assert.Equal(t, invoker.timeout, time.Duration(time.Millisecond*300))
+
+ // test for second
+ tmpMockUrl = mockDubbo3CommonUrl2 + "&timeout=1s"
+ url, err = common.NewURL(tmpMockUrl)
+ assert.Nil(t, err)
+
+ invoker, err = NewDubboInvoker(url)
+ assert.Nil(t, err)
+ assert.Equal(t, invoker.timeout, time.Duration(time.Second))
+
+ // test for timeout default config
+ url, err = common.NewURL(mockDubbo3CommonUrl2)
+ assert.Nil(t, err)
+
+ invoker, err = NewDubboInvoker(url)
+ assert.Nil(t, err)
+ assert.Equal(t, invoker.timeout, time.Duration(time.Second*3))
+}