This is an automated email from the ASF dual-hosted git repository. alexstocks pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/master by this push: new 2b3b74f Fix:fix test & some spelling problems new 0c3a607 Merge pull request #107 from fangyincheng/services 2b3b74f is described below commit 2b3b74f24ae93ae9cfca5cb9a890dd966dc3b615 Author: fangyincheng <fangyinch...@sina.com> AuthorDate: Thu Jun 27 20:07:03 2019 +0800 Fix:fix test & some spelling problems --- cluster/loadbalance/least_active.go | 2 +- config/service_config_test.go | 3 ++- protocol/dubbo/client_test.go | 6 +++--- protocol/dubbo/codec.go | 6 +++--- protocol/dubbo/dubbo_invoker_test.go | 2 +- protocol/dubbo/dubbo_protocol_test.go | 2 +- protocol/dubbo/listener.go | 2 +- protocol/jsonrpc/server.go | 4 +++- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go index d7d3056..695ca21 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/least_active.go @@ -50,7 +50,7 @@ func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation var ( leastActive int32 = -1 // The least active value of all invokers totalWeight int64 = 0 // The number of invokers having the same least active value (LEAST_ACTIVE) - firstWeight int64 = 0 // Initial value, used for comparision + firstWeight int64 = 0 // Initial value, used for comparison leastIndexes = make([]int, count) // The index of invokers having the same least active value (LEAST_ACTIVE) leastCount = 0 // The number of invokers having the same least active value (LEAST_ACTIVE) sameWeight = true // Every invoker has the same weight value? diff --git a/config/service_config_test.go b/config/service_config_test.go index 77cbbff..99835f6 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -122,7 +122,8 @@ func Test_Export(t *testing.T) { doinit() extension.SetProtocol("registry", GetProtocol) - for _, service := range providerConfig.Services { + for i := 0; i < len(providerConfig.Services); i++ { + service := providerConfig.Services[i] service.Implement(&MockService{}) service.Export() assert.Condition(t, func() bool { diff --git a/protocol/dubbo/client_test.go b/protocol/dubbo/client_test.go index 1ea9e4f..f4a5f4a 100644 --- a/protocol/dubbo/client_test.go +++ b/protocol/dubbo/client_test.go @@ -40,7 +40,7 @@ func TestClient_CallOneway(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) @@ -57,7 +57,7 @@ func TestClient_Call(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) @@ -118,7 +118,7 @@ func TestClient_AsyncCall(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) diff --git a/protocol/dubbo/codec.go b/protocol/dubbo/codec.go index e9ced84..cb57fc8 100644 --- a/protocol/dubbo/codec.go +++ b/protocol/dubbo/codec.go @@ -40,9 +40,9 @@ const ( type CallType int32 const ( - CT_UNKOWN CallType = 0 - CT_OneWay CallType = 1 - CT_TwoWay CallType = 2 + CT_UNKNOWN CallType = 0 + CT_OneWay CallType = 1 + CT_TwoWay CallType = 2 ) //////////////////////////////////////////// diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 4368bb4..182d6d8 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -36,7 +36,7 @@ func TestDubboInvoker_Invoke(t *testing.T) { proto, url := InitTest(t) c := &Client{ - pendingResponses: make(map[SequenceType]*PendingResponse), + pendingResponses: new(sync.Map), conf: *clientConf, } c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 3543d8d..26ce4a1 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -48,7 +48,7 @@ func TestDubboProtocol_Export(t *testing.T) { eq := exporter.GetInvoker().GetUrl().URLEqual(url) assert.True(t, eq) - // second service: the same path and the diferent version + // second service: the same path and the different version url2, err := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&"+ "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&"+ "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&"+ diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index 15e2226..55ee929 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -190,7 +190,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) { p, ok := pkg.(*DubboPackage) if !ok { - logger.Errorf("illegal packge{%#v}", pkg) + logger.Errorf("illegal package{%#v}", pkg) return } p.Header.ResponseStatus = hessian.Response_OK diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 5b55480..22dc7cf 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -152,7 +152,9 @@ func (s *Server) handlePkg(conn net.Conn) { timeout, err := time.ParseDuration(reqHeader["Timeout"]) if err == nil { httpTimeout = timeout - ctx, _ = context.WithTimeout(ctx, httpTimeout) + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, httpTimeout) + defer cancel() } delete(reqHeader, "Timeout") }