Skip to content

Commit

Permalink
fix timeout don't support ms bug (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Fight authored Nov 5, 2022
1 parent 188fc04 commit ef53b9b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion protocol/dubbo3/dubbo3_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")),
Expand Down
32 changes: 32 additions & 0 deletions protocol/dubbo3/dubbo3_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit ef53b9b

Please sign in to comment.