pantianying commented on a change in pull request #495:
URL: https://github.com/apache/dubbo-go/pull/495#discussion_r415877073
##########
File path: remoting/exchange_client.go
##########
@@ -0,0 +1,154 @@
+package remoting
+
+import (
+ "github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/logger"
+ "github.com/apache/dubbo-go/protocol"
+ "sync"
+ "time"
+)
+
+var (
+ pendingResponses *sync.Map = new(sync.Map)
+)
+
+type SequenceType int64
+
+type ExchangeClient struct {
+ ConnectTimeout time.Duration
+ address string
+ client Client
+}
+
+type Client interface {
+ SetExchangeClient(client *ExchangeClient)
+ SetResponseHandler(responseHandler ResponseHandler)
+ //invoke once for connection
+ Connect(url common.URL)
+ Close()
+ Request(request *Request, timeout time.Duration, callback
common.AsyncCallback, response *PendingResponse) error
+}
+
+type ResponseHandler interface {
+ Handler(response *Response)
+}
+
+func NewExchangeClient(url common.URL, client Client, connectTimeout
time.Duration) *ExchangeClient {
+ exchangeClient := &ExchangeClient{
+ ConnectTimeout: connectTimeout,
+ address: url.Location,
+ client: client,
+ }
+ client.SetExchangeClient(exchangeClient)
+ client.Connect(url)
Review comment:
client.Connect需要返回是否成功吧
##########
File path: remoting/exchange_client.go
##########
@@ -0,0 +1,154 @@
+package remoting
+
+import (
+ "github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/logger"
+ "github.com/apache/dubbo-go/protocol"
+ "sync"
+ "time"
+)
+
+var (
+ pendingResponses *sync.Map = new(sync.Map)
+)
+
+type SequenceType int64
+
+type ExchangeClient struct {
+ ConnectTimeout time.Duration
+ address string
+ client Client
+}
+
+type Client interface {
+ SetExchangeClient(client *ExchangeClient)
+ SetResponseHandler(responseHandler ResponseHandler)
+ //invoke once for connection
+ Connect(url common.URL)
+ Close()
+ Request(request *Request, timeout time.Duration, callback
common.AsyncCallback, response *PendingResponse) error
+}
+
+type ResponseHandler interface {
+ Handler(response *Response)
+}
+
+func NewExchangeClient(url common.URL, client Client, connectTimeout
time.Duration) *ExchangeClient {
+ exchangeClient := &ExchangeClient{
+ ConnectTimeout: connectTimeout,
+ address: url.Location,
+ client: client,
+ }
+ client.SetExchangeClient(exchangeClient)
+ client.Connect(url)
+ client.SetResponseHandler(exchangeClient)
+ return exchangeClient
+}
+
+func (client *ExchangeClient) Request(invocation *protocol.Invocation, url
common.URL, timeout time.Duration,
Review comment:
超时时间等需要每次请求再计算下 因为有method维度的配置
##########
File path: remoting/exchange_server.go
##########
@@ -0,0 +1,30 @@
+package remoting
+
+import (
+ "github.com/apache/dubbo-go/common"
+)
+
+type Server interface {
+ //invoke once for connection
+ Start()
+ Stop()
+}
+
+type ExchangeServer struct {
+ Server Server
+}
+
+func NewExchangeServer(url common.URL, server Server) *ExchangeServer {
+ exchangServer := &ExchangeServer{
+ Server: server,
+ }
+ return exchangServer
+}
+
+func (server *ExchangeServer) Start() {
+ (server.Server).Start()
Review comment:
是否必要加(server.Server)中的()
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]