From a86334000143e2722f23ae2057c63c477cf65988 Mon Sep 17 00:00:00 2001 From: haohongfan Date: Thu, 17 Sep 2020 00:11:01 +0800 Subject: [PATCH 1/2] feat: delete dubbo_protocol assert remoting.ExchangeClient --- protocol/dubbo/dubbo_protocol.go | 15 +++------------ protocol/jsonrpc/jsonrpc_invoker.go | 1 - remoting/getty/getty_server.go | 8 ++++---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 2826e64d92..b8e9b59eb7 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -48,8 +48,8 @@ const ( var ( // Make the connection can be shared. // It will create one connection for one address (ip+port) - exchangeClientMap *sync.Map = new(sync.Map) - exchangeLock *sync.Map = new(sync.Map) + exchangeClientMap = new(sync.Map) + exchangeLock = new(sync.Map) ) func init() { @@ -215,16 +215,7 @@ func getExchangeClient(url common.URL) *remoting.ExchangeClient { if clientTmp == nil { return nil } - exchangeClient, ok := clientTmp.(*remoting.ExchangeClient) - if !ok { - exchangeClientTmp := remoting.NewExchangeClient(url, getty.NewClient(getty.Options{ - ConnectTimeout: config.GetConsumerConfig().ConnectTimeout, - RequestTimeout: config.GetConsumerConfig().RequestTimeout}), config.GetConsumerConfig().ConnectTimeout, false) - if exchangeClientTmp != nil { - exchangeClientMap.Store(url.Location, exchangeClientTmp) - } - return exchangeClientTmp - } + exchangeClient := clientTmp.(*remoting.ExchangeClient) return exchangeClient } diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index 970d5f9a08..d84b980216 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -26,7 +26,6 @@ import ( "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/protocol" - invocation_impl "github.com/apache/dubbo-go/protocol/invocation" ) diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index 98ca690cbf..be2dfd6bed 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -95,7 +95,7 @@ func GetServerConfig() ServerConfig { return *srvConf } -// SetServerGrpool ... +// SetServerGrpool set getty server GrPool func SetServerGrpool() { if srvConf.GrPoolSize > 1 { srvGrpool = gxsync.NewTaskPool(gxsync.WithTaskPoolTaskPoolSize(srvConf.GrPoolSize), gxsync.WithTaskPoolTaskQueueLength(srvConf.QueueLen), @@ -103,7 +103,7 @@ func SetServerGrpool() { } } -// Server ... +// Server define getty server type Server struct { conf ServerConfig addr string @@ -113,7 +113,7 @@ type Server struct { requestHandler func(*invocation.RPCInvocation) protocol.RPCResult } -// NewServer ... +// NewServer create a new Server func NewServer(url common.URL, handlers func(*invocation.RPCInvocation) protocol.RPCResult) *Server { //init initServer(url.Protocol) @@ -210,7 +210,7 @@ func (s *Server) Start() { } -// Stop ... +// Stop dubbo server func (s *Server) Stop() { s.tcpServer.Close() } From 2d5b00461fa6d030d0bc6b9354f897876124a455 Mon Sep 17 00:00:00 2001 From: haohongfan Date: Thu, 17 Sep 2020 10:13:28 +0800 Subject: [PATCH 2/2] feat: merge one line --- protocol/dubbo/dubbo_protocol.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index b8e9b59eb7..8dda52b6b9 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -215,8 +215,7 @@ func getExchangeClient(url common.URL) *remoting.ExchangeClient { if clientTmp == nil { return nil } - exchangeClient := clientTmp.(*remoting.ExchangeClient) - return exchangeClient + return clientTmp.(*remoting.ExchangeClient) } // rebuildCtx rebuild the context by attachment.