You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/10/30 09:39:13 UTC

[dubbo-go] branch 3.0 updated: fix error log when building route chain in the case we didn't configure the config center (#1548)

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 7f1521c  fix error log when building route chain in the case we didn't configure the config center (#1548)
7f1521c is described below

commit 7f1521c38ea0f30c27f78f41a9378eac18176ff3
Author: Mulavar <97...@qq.com>
AuthorDate: Sat Oct 30 17:38:27 2021 +0800

    fix error log when building route chain in the case we didn't configure the config center (#1548)
    
    Co-authored-by: dongjianhui03 <do...@meituan.com>
    Co-authored-by: lizhixin.lzx <li...@alibaba-inc.com>
---
 cluster/router/chain/chain.go           | 6 ++++--
 cluster/router/v3router/router_chain.go | 7 ++++---
 config/config_center_config.go          | 3 ++-
 config/root_config.go                   | 2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index e366a2a..cc4ea5f 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -113,8 +113,10 @@ func NewRouterChain() (*RouterChain, error) {
 
 	for key, routerFactory := range routerFactories {
 		r, err := routerFactory().NewPriorityRouter()
-		if r == nil || err != nil {
-			logger.Errorf("router chain build router fail! routerFactories key:%s  error:%v", key, err)
+		if err != nil {
+			logger.Errorf("Build router chain failed with routerFactories key:%s and error:%v", key, err)
+			continue
+		} else if r == nil {
 			continue
 		}
 		routers = append(routers, r)
diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go
index 973f98e..427a053 100644
--- a/cluster/router/v3router/router_chain.go
+++ b/cluster/router/v3router/router_chain.go
@@ -48,10 +48,11 @@ func NewUniformRouterChain() (router.PriorityRouter, error) {
 	// 1. add mesh route listener
 	r := &RouterChain{}
 	rootConfig := config.GetRootConfig()
-	dynamicConfiguration, err := rootConfig.ConfigCenter.GetDynamicConfiguration()
-	if err != nil {
-		return nil, err
+	if rootConfig.ConfigCenter.DynamicConfiguration == nil {
+		logger.Infof("Config center does not start, please check if the configuration center has been properly configured in dubbogo.yml")
+		return nil, nil
 	}
+	dynamicConfiguration := rootConfig.ConfigCenter.DynamicConfiguration
 	dynamicConfiguration.AddListener(rootConfig.Application.Name, r)
 
 	// 2. try to get mesh route configuration, default key is "dubbo.io.MESHAPPRULE" with group "dubbo"
diff --git a/config/config_center_config.go b/config/config_center_config.go
index 956a39d..e33ba35 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -18,6 +18,7 @@
 package config
 
 import (
+	"fmt"
 	"net/url"
 	"strings"
 )
@@ -155,7 +156,7 @@ func (c *CenterConfig) CreateDynamicConfiguration() (config_center.DynamicConfig
 	}
 	factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol)
 	if factory == nil {
-		return nil, errors.New("get config center factory failed")
+		return nil, errors.New(fmt.Sprintf("Get config center factory of %s failed", configCenterUrl.Protocol))
 	}
 	return factory.GetDynamicConfiguration(configCenterUrl)
 }
diff --git a/config/root_config.go b/config/root_config.go
index 7db0a34..c1f185c 100644
--- a/config/root_config.go
+++ b/config/root_config.go
@@ -137,7 +137,7 @@ func (rc *RootConfig) Init() error {
 		return err
 	}
 	if err := rc.ConfigCenter.Init(rc); err != nil {
-		logger.Infof("config center doesn't start, because %s", err)
+		logger.Infof("Config center doesn't start,because %s", err)
 	} else {
 		if err := rc.Logger.Init(); err != nil { // init logger using config from config center again
 			return err