From 517f54d598518c16f309eca6313bba67b32c7628 Mon Sep 17 00:00:00 2001 From: haohongfan <haohongfan@ling.ai> Date: Thu, 17 Sep 2020 00:11:01 +0800 Subject: [PATCH] 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 2826e64d9..b8e9b59eb 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 970d5f9a0..d84b98021 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 98ca690cb..be2dfd6be 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() } -- GitLab