Skip to content

Commit

Permalink
fix remoting linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed Jan 2, 2021
1 parent 971c854 commit 70eb671
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module github.com/apache/dubbo-go

go 1.15

require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/RoaringBitmap/roaring v0.5.5
Expand Down Expand Up @@ -56,3 +54,4 @@ replace (
github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.4
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0
)

7 changes: 5 additions & 2 deletions remoting/getty/getty_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func getClient(url *common.URL) *Client {

exchangeClient := remoting.NewExchangeClient(url, client, 5*time.Second, false)
client.SetExchangeClient(exchangeClient)
client.Connect(url)
if err := client.Connect(url); err != nil {
return nil
}
return client
}

Expand Down Expand Up @@ -396,7 +398,8 @@ func InitTest(t *testing.T) (*Server, *common.URL) {
"side=provider&timeout=3000&timestamp=1556509797245&bean.name=UserProvider")
// init server
userProvider := &UserProvider{}
common.ServiceMap.Register("", url.Protocol, "", "0.0.1", userProvider)
_, err = common.ServiceMap.Register("", url.Protocol, "", "0.0.1", userProvider)
assert.NoError(t, err)
invoker := &proxy_factory.ProxyInvoker{
BaseInvoker: *protocol.NewBaseInvoker(url),
}
Expand Down
20 changes: 15 additions & 5 deletions remoting/getty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,23 @@ func (c *gettyRPCClient) newSession(session getty.Session) error {
panic(fmt.Sprintf("%s, session.conn{%#v} is not tcp connection\n", session.Stat(), session.Conn()))
}

tcpConn.SetNoDelay(conf.GettySessionParam.TcpNoDelay)
tcpConn.SetKeepAlive(conf.GettySessionParam.TcpKeepAlive)
if err := tcpConn.SetNoDelay(conf.GettySessionParam.TcpNoDelay); err != nil {
logger.Error("tcpConn.SetNoDelay() = error:%v", err)
}
if err := tcpConn.SetKeepAlive(conf.GettySessionParam.TcpKeepAlive); err != nil {
logger.Error("tcpConn.SetKeepAlive() = error:%v", err)
}
if conf.GettySessionParam.TcpKeepAlive {
tcpConn.SetKeepAlivePeriod(conf.GettySessionParam.keepAlivePeriod)
if err := tcpConn.SetKeepAlivePeriod(conf.GettySessionParam.keepAlivePeriod); err != nil {
logger.Error("tcpConn.SetKeepAlivePeriod() = error:%v", err)
}
}
if err := tcpConn.SetReadBuffer(conf.GettySessionParam.TcpRBufSize); err != nil {
logger.Error("tcpConn.SetReadBuffer() = error:%v", err)
}
if err := tcpConn.SetWriteBuffer(conf.GettySessionParam.TcpWBufSize); err != nil {
logger.Error("tcpConn.SetWriteBuffer() = error:%v", err)
}
tcpConn.SetReadBuffer(conf.GettySessionParam.TcpRBufSize)
tcpConn.SetWriteBuffer(conf.GettySessionParam.TcpWBufSize)

session.SetName(conf.GettySessionParam.SessionName)
session.SetMaxMsgLen(conf.GettySessionParam.MaxMsgLen)
Expand Down
25 changes: 20 additions & 5 deletions remoting/zookeeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.
func Test_newMockZookeeperClient(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer ts.Stop()
defer func() {
err := ts.Stop()
assert.Nil(t, err)
}()
states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
verifyEventStateOrder(t, event, states, "event channel")

Expand All @@ -92,7 +95,10 @@ func Test_newMockZookeeperClient(t *testing.T) {
func TestCreate(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer ts.Stop()
defer func() {
err := ts.Stop()
assert.Nil(t, err)
}()
err = z.Create("test1/test2/test3/test4")
assert.NoError(t, err)

Expand All @@ -103,7 +109,10 @@ func TestCreate(t *testing.T) {
func TestCreateDelete(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer ts.Stop()
defer func() {
err := ts.Stop()
assert.Nil(t, err)
}()

states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
verifyEventStateOrder(t, event, states, "event channel")
Expand All @@ -117,7 +126,10 @@ func TestCreateDelete(t *testing.T) {
func TestRegisterTemp(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer ts.Stop()
defer func() {
err := ts.Stop()
assert.Nil(t, err)
}()
err = z.Create("/test1/test2/test3")
assert.NoError(t, err)

Expand All @@ -131,7 +143,10 @@ func TestRegisterTemp(t *testing.T) {
func TestRegisterTempSeq(t *testing.T) {
ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer ts.Stop()
defer func() {
err := ts.Stop()
assert.Nil(t, err)
}()
err = z.Create("/test1/test2/test3")
assert.NoError(t, err)
tmpath, err := z.RegisterTempSeq("/test1/test2/test3", []byte("test"))
Expand Down

0 comments on commit 70eb671

Please sign in to comment.