From e73d5cc7e116c100ff26450f5266f73a62a09f07 Mon Sep 17 00:00:00 2001 From: "xg.gao" <xg.gao@tianrang-inc.com> Date: Thu, 20 Aug 2020 14:09:36 +0800 Subject: [PATCH] format --- config/service_config.go | 2 +- registry/protocol/protocol.go | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 2b074b80c..e1c9a5b18 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -133,7 +133,7 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) if err != nil { - panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) + panic(perrors.New(fmt.Sprintf("Get tcp port error, err is {%v}", err))) } defer tcp.Close() ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 95f8155ee..50b056c54 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -22,6 +22,7 @@ import ( "strings" "sync" ) + import ( gxset "github.com/dubbogo/gost/container/set" ) @@ -54,9 +55,10 @@ var ( type registryProtocol struct { invokers []protocol.Invoker - // Registry Map<RegistryAddress, Registry> + // Registry Map<RegistryAddress, Registry> registries *sync.Map - // To solve the problem of RMI repeated exposure port conflicts, the services that have been exposed are no longer exposed. + // To solve the problem of RMI repeated exposure port conflicts, + // the services that have been exposed are no longer exposed. // providerurl <--> exporter bounds *sync.Map overrideListeners *sync.Map @@ -100,7 +102,6 @@ func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common. // filterHideKey filter the parameters that do not need to be output in url(Starting with .) func filterHideKey(url *common.URL) *common.URL { - // be careful params maps in url is map type removeSet := gxset.NewSet() for k, _ := range url.GetParams() { @@ -127,7 +128,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { } var reg registry.Registry - if regI, loaded := proto.registries.Load(registryUrl.Key()); !loaded { reg = getRegistry(®istryUrl) proto.registries.Store(registryUrl.Key(), reg) @@ -138,7 +138,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { // new registry directory for store service url from registry directory, err := extension.GetDefaultRegistryDirectory(®istryUrl, reg) if err != nil { - logger.Errorf("consumer service %v create registry directory error, error message is %s, and will return nil invoker!", + logger.Errorf("consumer service %v create registry directory error, error message is %s, and will return nil invoker!", serviceUrl.String(), err.Error()) return nil } @@ -151,7 +151,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { // new cluster invoker cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) - invoker := cluster.Join(directory) proto.invokers = append(proto.invokers, invoker) return invoker @@ -192,7 +191,7 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte } key := getCacheKey(providerUrl) - logger.Infof("The cached exporter keys is %v !", key) + logger.Infof("The cached exporter keys is %v!", key) cachedExporter, loaded := proto.bounds.Load(key) if loaded { logger.Infof("The exporter has been cached, and will return cached exporter!") @@ -216,7 +215,6 @@ func (proto *registryProtocol) reExport(invoker protocol.Invoker, newUrl *common proto.bounds.Delete(key) proto.Export(wrappedNewInvoker) // TODO: unregister & unsubscribe - } } @@ -353,7 +351,7 @@ func (proto *registryProtocol) Destroy() { func getRegistryUrl(invoker protocol.Invoker) *common.URL { // here add * for return a new url url := invoker.GetUrl() - // if the protocol == registry ,set protocol the registry value in url.params + // if the protocol == registry, set protocol the registry value in url.params if url.Protocol == constant.REGISTRY_PROTOCOL { protocol := url.GetParam(constant.REGISTRY_KEY, "") url.Protocol = protocol -- GitLab