diff --git a/config/reference_config.go b/config/reference_config.go index 65bbfd2b31998b7a8f06b0721264d52333c4cd2f..0009dc87c9f2a6deb16b5557e5ecb177016b1b1e 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -90,7 +90,11 @@ func (refconfig *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) erro } func (refconfig *ReferenceConfig) Refer(impl interface{}) { - url := common.NewURLWithOptions(common.WithPath(refconfig.id), common.WithProtocol(refconfig.Protocol), common.WithParams(refconfig.getUrlMap())) + url := common.NewURLWithOptions(common.WithPath(refconfig.id), + common.WithProtocol(refconfig.Protocol), + common.WithParams(refconfig.getUrlMap()), + common.WithParamsValue(constant.BEAN_NAME_KEY, refconfig.id), + ) //1. user specified URL, could be peer-to-peer address, or register center's address. if refconfig.Url != "" { @@ -123,12 +127,12 @@ func (refconfig *ReferenceConfig) Refer(impl interface{}) { } } if len(refconfig.urls) == 1 { - refconfig.invoker = extension.GetProtocol(refconfig.urls[0].Protocol).Refer(*refconfig.urls[0], impl) + refconfig.invoker = extension.GetProtocol(refconfig.urls[0].Protocol).Refer(*refconfig.urls[0]) } else { invokers := []protocol.Invoker{} var regUrl *common.URL for _, u := range refconfig.urls { - invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u, impl)) + invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u)) if u.Protocol == constant.REGISTRY_PROTOCOL { regUrl = u } diff --git a/config/reference_config_test.go b/config/reference_config_test.go index 39e67c1095af8a526def3156f7585302b7ac4c04..7a65e55f09c997cb49b83f1f185faf9338cf0f5a 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -324,7 +324,7 @@ func newRegistryProtocol() protocol.Protocol { type mockRegistryProtocol struct{} -func (*mockRegistryProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (*mockRegistryProtocol) Refer(url common.URL) protocol.Invoker { return protocol.NewBaseInvoker(url) } diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index cf395556a6aba27b892f1e2541a27dae2c01aebf..eed22a29cde59b520f1b6ebf9b5baafabcac931f 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -68,7 +68,7 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { return exporter } -func (dp *DubboProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (dp *DubboProtocol) Refer(url common.URL) protocol.Invoker { //default requestTimeout var requestTimeout = config.GetConsumerConfig().RequestTimeout diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 65ee17a2adc36eb33930b3911cd69810c4642875..a6b0bc1df3cf2eb46e07c9dab149d04f62f78012 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -85,7 +85,7 @@ func TestDubboProtocol_Refer(t *testing.T) { "side=provider&timeout=3000×tamp=1556509797245") assert.NoError(t, err) clientConf = &ClientConfig{} - invoker := proto.Refer(url, nil) + invoker := proto.Refer(url) // make sure url eq := invoker.GetUrl().URLEqual(url) diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 5ecc9c3ce5fd4037f06cf473754a59bc0e29de2b..01eeb31a70bb61dc1a170d6640f540316518b19f 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -18,6 +18,8 @@ limitations under the License. package grpc import ( + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/config" "reflect" ) @@ -34,12 +36,14 @@ type Client struct { invoker reflect.Value } -func NewClient(impl interface{}, url common.URL) *Client { +func NewClient(url common.URL) *Client { conn, err := grpc.Dial(url.Location, grpc.WithInsecure(), grpc.WithBlock()) if err != nil { panic(err) } + key := url.GetParam(constant.BEAN_NAME_KEY, "") + impl := config.GetConsumerService(key) invoker := getInvoker(impl, conn) return &Client{ diff --git a/protocol/grpc/client_test.go b/protocol/grpc/client_test.go index 99db4a21cde7d573c1a43f5b5d252f16010b9953..7d96402782999393fc9ddf7b6c058509e342b366 100644 --- a/protocol/grpc/client_test.go +++ b/protocol/grpc/client_test.go @@ -47,9 +47,8 @@ func TestNewClient(t *testing.T) { go internal.InitGrpcServer() defer internal.ShutdownGrpcServer() - var impl *internal.GrpcGreeterImpl url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!") assert.Nil(t, err) - cli := NewClient(impl, url) + cli := NewClient(url) assert.NotNil(t, cli) } diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go index 3743236ae66424262ba8d954311396657e581fcb..4f97e1063191692ce5f47e0d4f8242d95cc8a6fc 100644 --- a/protocol/grpc/grpc_invoker_test.go +++ b/protocol/grpc/grpc_invoker_test.go @@ -37,11 +37,10 @@ func TestInvoke(t *testing.T) { go internal.InitGrpcServer() defer internal.ShutdownGrpcServer() - var impl *internal.GrpcGreeterImpl url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!") assert.Nil(t, err) - cli := NewClient(impl, url) + cli := NewClient(url) invoker := NewGrpcInvoker(url, cli) diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go index fb2df33bd257d94a26addcfe5af3686dc4da297f..cad75752ad5bbd66084379d37280cc04dbc72e2f 100644 --- a/protocol/grpc/grpc_protocol.go +++ b/protocol/grpc/grpc_protocol.go @@ -78,8 +78,8 @@ func (gp *GrpcProtocol) openServer(url common.URL) { } } -func (gp *GrpcProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker { - invoker := NewGrpcInvoker(url, NewClient(impl, url)) +func (gp *GrpcProtocol) Refer(url common.URL) protocol.Invoker { + invoker := NewGrpcInvoker(url, NewClient(url)) gp.SetInvokers(invoker) logger.Infof("Refer service: %s", url.String()) return invoker diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 541a80da5f0a716086678ecf84ab57b452102a17..e4629499b73c3fc4116a355bd66f440e95fe5451 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -70,8 +70,7 @@ func TestGrpcProtocol_Refer(t *testing.T) { proto := GetProtocol() url, err := common.NewURL(context.Background(), "grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!") assert.NoError(t, err) - var impl *internal.GrpcGreeterImpl - invoker := proto.Refer(url, impl) + invoker := proto.Refer(url) // make sure url eq := invoker.GetUrl().URLEqual(url) diff --git a/protocol/grpc/internal/client.go b/protocol/grpc/internal/client.go index 4703f430840f8e68ff4142de1eae1565784dd107..5e4149d2cc6dd69c5bc10776fc0b1db60d8358cb 100644 --- a/protocol/grpc/internal/client.go +++ b/protocol/grpc/internal/client.go @@ -19,12 +19,17 @@ package internal import ( "context" + "github.com/apache/dubbo-go/config" ) import ( "google.golang.org/grpc" ) +func init() { + config.SetConsumerService(&GrpcGreeterImpl{}) +} + // used for dubbo-grpc biz client type GrpcGreeterImpl struct { SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error diff --git a/protocol/grpc/internal/helloworld.pb.go b/protocol/grpc/internal/helloworld.pb.go index 83c2bc253502c95756cd8c65322b56944295f8d2..79b74ac65011208ae74f989cf86e4e6f9f446015 100644 --- a/protocol/grpc/internal/helloworld.pb.go +++ b/protocol/grpc/internal/helloworld.pb.go @@ -1,3 +1,20 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + // Code generated by protoc-gen-go. DO NOT EDIT. // source: helloworld.proto diff --git a/protocol/grpc/protoc-gen-dubbo/examples/Makefile b/protocol/grpc/protoc-gen-dubbo/examples/Makefile index 7df4010b3f2aade1cf7b1826b9523c84a7d29020..7893bbc51aa436f711bfb653dc81d9ec66b7e5c0 100644 --- a/protocol/grpc/protoc-gen-dubbo/examples/Makefile +++ b/protocol/grpc/protoc-gen-dubbo/examples/Makefile @@ -1,3 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + grpc-gen: protoc -I ./ helloworld.proto --go_out=plugins=grpc:. dubbo-gen: diff --git a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go index 33d47e095b654ab0dbe1ce951c44dd90dc945c4f..4ed55ab7612200d28816508e4c4fcb7de0a803c0 100644 --- a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go +++ b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go @@ -1,3 +1,20 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + // Code generated by protoc-gen-go. DO NOT EDIT. // source: helloworld.proto diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 679478766123cd14c45c3a27c6604e1ef4bc69c2..a2e7afe69a138e0cd6dbbe05b3f386647895ee15 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -67,7 +67,7 @@ func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter { return exporter } -func (jp *JsonrpcProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (jp *JsonrpcProtocol) Refer(url common.URL) protocol.Invoker { //default requestTimeout var requestTimeout = config.GetConsumerConfig().RequestTimeout diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 5b6a6043cb6aab206105c4093b18fca060c31bad..253ab830dd85e5424811b7fd4e7e7e848adad415 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -80,7 +80,7 @@ func TestJsonrpcProtocol_Refer(t *testing.T) { RequestTimeout: 5 * time.Second, } config.SetConsumerConfig(con) - invoker := proto.Refer(url, nil) + invoker := proto.Refer(url) // make sure url eq := invoker.GetUrl().URLEqual(url) diff --git a/protocol/protocol.go b/protocol/protocol.go index 93f57b77a704924b1523288c2406012e49c463d1..814a85163a99aa3b161b5eafbfed5f13ac4e3eb4 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -29,7 +29,7 @@ import ( // Extension - protocol type Protocol interface { Export(invoker Invoker) Exporter - Refer(url common.URL, impl interface{}) Invoker + Refer(url common.URL) Invoker Destroy() } @@ -74,7 +74,7 @@ func (bp *BaseProtocol) Export(invoker Invoker) Exporter { return NewBaseExporter("base", invoker, bp.exporterMap) } -func (bp *BaseProtocol) Refer(url common.URL, impl interface{}) Invoker { +func (bp *BaseProtocol) Refer(url common.URL) Invoker { return NewBaseInvoker(url) } diff --git a/protocol/protocolwrapper/mock_protocol_filter.go b/protocol/protocolwrapper/mock_protocol_filter.go index 4f1e5638e31aa050c26729faffe48cb0ffe8b1b8..2efc34da4469cf369d4bbeb871ccfbdb73123f6a 100644 --- a/protocol/protocolwrapper/mock_protocol_filter.go +++ b/protocol/protocolwrapper/mock_protocol_filter.go @@ -36,7 +36,7 @@ func (pfw *mockProtocolFilter) Export(invoker protocol.Invoker) protocol.Exporte return protocol.NewBaseExporter("key", invoker, &sync.Map{}) } -func (pfw *mockProtocolFilter) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (pfw *mockProtocolFilter) Refer(url common.URL) protocol.Invoker { return protocol.NewBaseInvoker(url) } diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go index e9cc5420639ed89a0966dad59bf29c2881403fad..7c58fabea3cccf5a39e1622fedd4a3a297e05983 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper.go @@ -50,11 +50,11 @@ func (pfw *ProtocolFilterWrapper) Export(invoker protocol.Invoker) protocol.Expo return pfw.protocol.Export(invoker) } -func (pfw *ProtocolFilterWrapper) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (pfw *ProtocolFilterWrapper) Refer(url common.URL) protocol.Invoker { if pfw.protocol == nil { pfw.protocol = extension.GetProtocol(url.Protocol) } - return buildInvokerChain(pfw.protocol.Refer(url, impl), constant.REFERENCE_FILTER_KEY) + return buildInvokerChain(pfw.protocol.Refer(url), constant.REFERENCE_FILTER_KEY) } func (pfw *ProtocolFilterWrapper) Destroy() { diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 103f0fb53e4aa8e150bb5b9b7ad4b127b6320d07..dc376313549c24da1cc6cb64a42e8445ef4fe346 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -54,7 +54,7 @@ func TestProtocolFilterWrapper_Refer(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), common.WithParamsValue(constant.REFERENCE_FILTER_KEY, "echo")) - invoker := filtProto.Refer(*u, nil) + invoker := filtProto.Refer(*u) _, ok := invoker.(*FilterInvoker) assert.True(t, ok) } diff --git a/registry/directory/directory.go b/registry/directory/directory.go index ad4a1cbd5c14308fda7f7016091b0dcd3cf0e52d..e88c611f6f20bc182c3630e328caab848affc08b 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -58,11 +58,10 @@ type registryDirectory struct { configurators []config_center.Configurator consumerConfigurationListener *consumerConfigurationListener referenceConfigurationListener *referenceConfigurationListener - impl interface{} Options } -func NewRegistryDirectory(url *common.URL, impl interface{}, registry registry.Registry, opts ...Option) (*registryDirectory, error) { +func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...Option) (*registryDirectory, error) { options := Options{ //default 300s serviceTTL: time.Duration(300e9), @@ -80,7 +79,6 @@ func NewRegistryDirectory(url *common.URL, impl interface{}, registry registry.R serviceType: url.SubURL.Service(), registry: registry, Options: options, - impl: impl, } dir.consumerConfigurationListener = newConsumerConfigurationListener(dir) return dir, nil @@ -200,13 +198,13 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) { dir.overrideUrl(newUrl) if cacheInvoker, ok := dir.cacheInvokersMap.Load(newUrl.Key()); !ok { logger.Infof("service will be added in cache invokers: invokers url is %s!", newUrl) - newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl, dir.impl) + newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl) if newInvoker != nil { dir.cacheInvokersMap.Store(newUrl.Key(), newInvoker) } } else { logger.Infof("service will be updated in cache invokers: new invoker url is %s, old invoker url is %s", newUrl, cacheInvoker.(protocol.Invoker).GetUrl()) - newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl, dir.impl) + newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(*newUrl) if newInvoker != nil { dir.cacheInvokersMap.Store(newUrl.Key(), newInvoker) cacheInvoker.(protocol.Invoker).Destroy() diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 9af4ef96a3e38438df136a6ccdd7794c411d295f..b3c1d35aaa66b3437ff89807fba2df0a383921cb 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -64,7 +64,7 @@ func TestSubscribe(t *testing.T) { func TestSubscribe_InvalidUrl(t *testing.T) { url, _ := common.NewURL(context.TODO(), "mock://127.0.0.1:1111") mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - _, err := NewRegistryDirectory(&url, nil, mockRegistry) + _, err := NewRegistryDirectory(&url, mockRegistry) assert.Error(t, err) } @@ -77,7 +77,7 @@ func TestSubscribe_Group(t *testing.T) { suburl.SetParam(constant.CLUSTER_KEY, "mock") regurl.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - registryDirectory, _ := NewRegistryDirectory(®url, nil, mockRegistry) + registryDirectory, _ := NewRegistryDirectory(®url, mockRegistry) go registryDirectory.Subscribe(common.NewURLWithOptions(common.WithPath("testservice"))) @@ -183,7 +183,7 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR ) url.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - registryDirectory, _ := NewRegistryDirectory(&url, nil, mockRegistry) + registryDirectory, _ := NewRegistryDirectory(&url, mockRegistry) go registryDirectory.Subscribe(&suburl) if len(noMockEvent) == 0 { diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 1bcc4d72ca98b31a0288323e4cff7aecf243868d..8655312a4eb508dfe5c910855ba5f3e3aacd666e 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -89,7 +89,7 @@ func (proto *registryProtocol) initConfigurationListeners() { proto.serviceConfigurationListeners = &sync.Map{} proto.providerConfigurationListener = newProviderConfigurationListener(proto.overrideListeners) } -func (proto *registryProtocol) Refer(url common.URL, impl interface{}) protocol.Invoker { +func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { var registryUrl = url var serviceUrl = registryUrl.SubURL @@ -108,7 +108,7 @@ func (proto *registryProtocol) Refer(url common.URL, impl interface{}) protocol. } //new registry directory for store service url from registry - directory, err := directory2.NewRegistryDirectory(®istryUrl, impl, reg) + directory, err := directory2.NewRegistryDirectory(®istryUrl, reg) if err != nil { logger.Errorf("consumer service %v create registry directory error, error message is %s, and will return nil invoker!", serviceUrl.String(), err.Error()) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 2c407cf2dc2ed346febd983f6ebb81c16c60de6d..0c19da59df6e4fd2f663f9e8d541165fe26c3ffa 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -60,7 +60,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { url.SubURL = &suburl - invoker := regProtocol.Refer(url, nil) + invoker := regProtocol.Refer(url) assert.IsType(t, &protocol.BaseInvoker{}, invoker) assert.Equal(t, invoker.GetUrl().String(), url.String()) } @@ -85,7 +85,7 @@ func TestMultiRegRefer(t *testing.T) { url2.SubURL = &suburl2 - regProtocol.Refer(url2, nil) + regProtocol.Refer(url2) var count int regProtocol.registries.Range(func(key, value interface{}) bool { count++ @@ -107,7 +107,7 @@ func TestOneRegRefer(t *testing.T) { url2.SubURL = &suburl2 - regProtocol.Refer(url2, nil) + regProtocol.Refer(url2) var count int regProtocol.registries.Range(func(key, value interface{}) bool { count++ diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 96aa45216ad842343836ddff12a921d3bd6a7ca9..0b9db5e09d9e2a81d4545bb03b979b3623cd217d 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -18,7 +18,6 @@ package zookeeper import ( - "fmt" "path" "strings" "sync" @@ -241,7 +240,6 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi //listen sub path recursive go func(zkPath string, listener remoting.DataListener) { - fmt.Printf("zkpath: %v \n", zkPath) l.listenDirEvent(zkPath, listener) logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath) }(dubboPath, listener)