From c3ad99b6e1894c638a84be730e4467d72ec985f4 Mon Sep 17 00:00:00 2001 From: fangyincheng <fangyincheng@sina.com> Date: Mon, 1 Apr 2019 14:29:10 +0800 Subject: [PATCH] Mod:fix bug --- examples/dubbo/go-client/app/client.go | 2 +- examples/jsonrpc/go-client/app/client.go | 2 +- examples/jsonrpc/go-client/app/test.go | 6 +++--- registry/zookeeper/consumer.go | 6 +++--- registry/zookeeper/registry.go | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/dubbo/go-client/app/client.go b/examples/dubbo/go-client/app/client.go index b0e1a51f4..6adeecbe1 100644 --- a/examples/dubbo/go-client/app/client.go +++ b/examples/dubbo/go-client/app/client.go @@ -93,7 +93,7 @@ func initClient(clientConfig *examples.ClientConfig) { } for _, service := range clientConfig.Service_List { - err = clientRegistry.RegisterConsumer(&service) + err = clientRegistry.RegisterConsumer(service) if err != nil { panic(fmt.Sprintf("registry.Register(service{%#v}) = error{%v}", service, jerrors.ErrorStack(err))) return diff --git a/examples/jsonrpc/go-client/app/client.go b/examples/jsonrpc/go-client/app/client.go index bddf1da15..ed394b223 100644 --- a/examples/jsonrpc/go-client/app/client.go +++ b/examples/jsonrpc/go-client/app/client.go @@ -96,7 +96,7 @@ func initClient(clientConfig *examples.ClientConfig) { } for _, service := range clientConfig.Service_List { - err = clientRegistry.RegisterConsumer(&service) + err = clientRegistry.RegisterConsumer(service) if err != nil { panic(fmt.Sprintf("registry.Register(service{%#v}) = error{%v}", service, jerrors.ErrorStack(err))) return diff --git a/examples/jsonrpc/go-client/app/test.go b/examples/jsonrpc/go-client/app/test.go index fb3d008b0..ac0053e0a 100644 --- a/examples/jsonrpc/go-client/app/test.go +++ b/examples/jsonrpc/go-client/app/test.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "github.com/dubbo/dubbo-go/registry" _ "net/http/pprof" ) @@ -14,7 +15,6 @@ import ( "github.com/dubbo/dubbo-go/examples" "github.com/dubbo/dubbo-go/jsonrpc" "github.com/dubbo/dubbo-go/public" - "github.com/dubbo/dubbo-go/service" ) func testJsonrpc(clientConfig *examples.ClientConfig, userKey string, method string) { @@ -24,7 +24,7 @@ func testJsonrpc(clientConfig *examples.ClientConfig, userKey string, method str serviceIdx int user *JsonRPCUser ctx context.Context - conf service.ServiceConfig + conf registry.ServiceConfig req jsonrpc.Request ) @@ -42,7 +42,7 @@ func testJsonrpc(clientConfig *examples.ClientConfig, userKey string, method str // Create request // gxlog.CInfo("jsonrpc selected service %#v", clientConfig.Service_List[serviceIdx]) - conf = service.ServiceConfig{ + conf = registry.ServiceConfig{ Group: clientConfig.Service_List[serviceIdx].Group, Protocol: public.CodecType(public.CODECTYPE_JSONRPC).String(), Version: clientConfig.Service_List[serviceIdx].Version, diff --git a/registry/zookeeper/consumer.go b/registry/zookeeper/consumer.go index c5073db90..9f4e9201c 100644 --- a/registry/zookeeper/consumer.go +++ b/registry/zookeeper/consumer.go @@ -19,10 +19,10 @@ func (r *ZkRegistry) RegisterConsumer(regConf registry.ServiceConfigIf) error { ok bool err error listener *zkEventListener - conf *registry.ServiceConfig + conf registry.ServiceConfig ) - if conf, ok = regConf.(*registry.ServiceConfig); !ok { + if conf, ok = regConf.(registry.ServiceConfig); !ok { return jerrors.Errorf("the type of @regConf %T is not registry.ServiceConfig", regConf) } @@ -48,7 +48,7 @@ func (r *ZkRegistry) RegisterConsumer(regConf registry.ServiceConfigIf) error { listener = r.listener r.listenerLock.Unlock() if listener != nil { - go listener.listenServiceEvent(conf) + go listener.listenServiceEvent(&conf) } return nil diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 8f7502734..a65f68d56 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -278,7 +278,7 @@ func (r *ZkRegistry) register(c registry.ServiceConfigIf) error { if r.DubboType == registry.PROVIDER { conf, ok := c.(registry.ProviderServiceConfig) if !ok { - return fmt.Errorf("the type of @c:%+v is not *registry.ProviderServiceConfig", c) + return fmt.Errorf("the type of @c:%+v is not registry.ProviderServiceConfig", c) } if conf.Service == "" || conf.Methods == "" { @@ -331,9 +331,9 @@ func (r *ZkRegistry) register(c registry.ServiceConfigIf) error { log.Debug("provider path:%s, url:%s", dubboPath, rawURL) } else if r.DubboType == registry.CONSUMER { - conf, ok := c.(*registry.ServiceConfig) - if ok { - return fmt.Errorf("the type of @c:%+v is not *registry.ServiceConfig", c) + conf, ok := c.(registry.ServiceConfig) + if !ok { + return fmt.Errorf("the type of @c:%+v is not registry.ServiceConfig", c) } dubboPath = fmt.Sprintf("/dubbo/%s/%s", conf.Service, registry.DubboNodes[registry.CONSUMER]) -- GitLab