You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ju...@apache.org on 2022/02/22 03:16:56 UTC

[dubbo-go] 01/01: Revert "Feature/adapt config"

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

justxuewei pushed a commit to branch revert-1759-feature/adapt-config
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit 412c5474b0bd4aa53b42f797ff2fc2a5a3b4c4f3
Author: Xuewei Niu <ju...@apache.org>
AuthorDate: Tue Feb 22 11:16:53 2022 +0800

    Revert "Feature/adapt config"
---
 common/constant/default.go     | 2 +-
 common/constant/key.go         | 1 -
 config/registry_config.go      | 1 -
 config_center/nacos/impl.go    | 2 +-
 registry/etcdv3/registry.go    | 2 +-
 registry/nacos/registry.go     | 2 +-
 remoting/nacos/builder.go      | 2 +-
 remoting/nacos/builder_test.go | 8 ++++----
 8 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/common/constant/default.go b/common/constant/default.go
index 2671f06..f84ffe1 100644
--- a/common/constant/default.go
+++ b/common/constant/default.go
@@ -33,7 +33,7 @@ const (
 	DefaultRetries          = "2"
 	DefaultRetriesInt       = 2
 	DefaultProtocol         = "dubbo"
-	DefaultRegTimeout       = "5s"
+	DefaultRegTimeout       = "10s"
 	DefaultRegTTL           = "15m"
 	DefaultCluster          = "failover"
 	DefaultFailbackTimes    = "3"
diff --git a/common/constant/key.go b/common/constant/key.go
index 4156c55..2b7ef46 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -250,7 +250,6 @@ const (
 	NacosLogLevelKey          = "nacos.logLevel"
 	NacosUsername             = "nacos.username"
 	NacosPassword             = "nacos.password"
-	NacosTimeout              = "nacos.timeout"
 )
 
 const (
diff --git a/config/registry_config.go b/config/registry_config.go
index 22cc58f..a879718 100644
--- a/config/registry_config.go
+++ b/config/registry_config.go
@@ -164,7 +164,6 @@ func (c *RegistryConfig) toURL(roleType common.RoleType) (*common.URL, error) {
 		common.WithParamsValue(constant.RegistrySimplifiedKey, strconv.FormatBool(c.Simplified)),
 		common.WithParamsValue(constant.RegistryKey, c.Protocol),
 		common.WithParamsValue(constant.RegistryNamespaceKey, c.Namespace),
-		common.WithParamsValue(constant.RegistryTimeoutKey, c.Timeout),
 		common.WithUsername(c.Username),
 		common.WithPassword(c.Password),
 		common.WithLocation(c.Address),
diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index f7e3f1f..4d044d2 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -68,7 +68,7 @@ func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration,
 	url.SetParam(constant.NacosPassword, url.Password)
 	url.SetParam(constant.NacosAccessKey, url.GetParam(constant.ConfigAccessKey, ""))
 	url.SetParam(constant.NacosSecretKey, url.GetParam(constant.ConfigSecretKey, ""))
-	url.SetParam(constant.NacosTimeout, url.GetParam(constant.ConfigTimeoutKey, ""))
+	url.SetParam(constant.TimeoutKey, url.GetParam(constant.ConfigTimeoutKey, ""))
 	url.SetParam(constant.NacosGroupKey, url.GetParam(constant.ConfigGroupKey, constant2.DEFAULT_GROUP))
 	c := &nacosDynamicConfiguration{
 		url:  url,
diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go
index f730401..2576021 100644
--- a/registry/etcdv3/registry.go
+++ b/registry/etcdv3/registry.go
@@ -74,7 +74,7 @@ func (r *etcdV3Registry) ClientLock() *sync.Mutex {
 }
 
 func newETCDV3Registry(url *common.URL) (registry.Registry, error) {
-	timeout := url.GetParamDuration(constant.RegistryTimeoutKey, constant.DefaultRegTimeout)
+	timeout := url.GetParamDuration(constant.ConfigTimeoutKey, constant.DefaultRegTimeout)
 
 	logger.Infof("etcd address is: %v, timeout is: %s", url.Location, timeout.String())
 
diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go
index daf6d66..07520fc 100644
--- a/registry/nacos/registry.go
+++ b/registry/nacos/registry.go
@@ -274,7 +274,7 @@ func newNacosRegistry(url *common.URL) (registry.Registry, error) {
 	url.SetParam(constant.NacosPassword, url.Password)
 	url.SetParam(constant.NacosAccessKey, url.GetParam(constant.RegistryAccessKey, ""))
 	url.SetParam(constant.NacosSecretKey, url.GetParam(constant.RegistrySecretKey, ""))
-	url.SetParam(constant.NacosTimeout, url.GetParam(constant.RegistryTimeoutKey, constant.DefaultRegTimeout))
+	url.SetParam(constant.TimeoutKey, url.GetParam(constant.RegistryTimeoutKey, ""))
 	url.SetParam(constant.NacosGroupKey, url.GetParam(constant.RegistryGroupKey, defaultGroup))
 	namingClient, err := nacos.NewNacosClientByURL(url)
 	if err != nil {
diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go
index fe5acf3..123796a 100644
--- a/remoting/nacos/builder.go
+++ b/remoting/nacos/builder.go
@@ -84,7 +84,7 @@ func GetNacosConfig(url *common.URL) ([]nacosConstant.ServerConfig, nacosConstan
 		serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{IpAddr: ip, Port: uint64(port), ContextPath: contextPath})
 	}
 
-	timeout := url.GetParamDuration(constant.NacosTimeout, constant.DefaultRegTimeout)
+	timeout := url.GetParamDuration(constant.TimeoutKey, constant.DefaultRegTimeout)
 
 	clientConfig := nacosConstant.ClientConfig{
 		TimeoutMs:           uint64(int32(timeout / time.Millisecond)),
diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go
index 2fdfa10..4ac09ec 100644
--- a/remoting/nacos/builder_test.go
+++ b/remoting/nacos/builder_test.go
@@ -114,19 +114,19 @@ func TestTimeoutConfig(t *testing.T) {
 		_, cc, err := GetNacosConfig(newURL)
 		assert.Nil(t, err)
 
-		assert.Equal(t, cc.TimeoutMs, uint64(int32(5*time.Second/time.Millisecond)))
+		assert.Equal(t, cc.TimeoutMs, uint64(int32(10*time.Second/time.Millisecond)))
 	})
 
 	t.Run("right timeout", func(t *testing.T) {
 
-		regurlMap.Set(constant.NacosTimeout, "7s")
+		regurlMap.Set(constant.TimeoutKey, "5s")
 
 		newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
 
 		_, cc, err := GetNacosConfig(newURL)
 		assert.Nil(t, err)
 
-		assert.Equal(t, cc.TimeoutMs, uint64(int32(7*time.Second/time.Millisecond)))
+		assert.Equal(t, cc.TimeoutMs, uint64(int32(5*time.Second/time.Millisecond)))
 	})
 
 	t.Run("invalid timeout", func(t *testing.T) {
@@ -136,7 +136,7 @@ func TestTimeoutConfig(t *testing.T) {
 		_, cc, err := GetNacosConfig(newURL)
 		assert.Nil(t, err)
 
-		assert.NotEqual(t, cc.TimeoutMs, uint64(int32(3*time.Second/time.Millisecond)))
+		assert.Equal(t, cc.TimeoutMs, uint64(int32(3*time.Second/time.Millisecond)))
 	})
 
 }