Skip to content

Commit

Permalink
Merge pull request #1576 from Mulavar/fix/nacos-namespace
Browse files Browse the repository at this point in the history
[#1573]1.5 fix the nacos namespace from server/client.yml does not take e…
  • Loading branch information
zhaoyunxing92 authored Nov 10, 2021
2 parents 22ec982 + 2cb57ab commit 5a90f47
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions config/config_center_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
//
// ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo
type ConfigCenterConfig struct {
//context context.Context
Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
Address string `yaml:"address" json:"address,omitempty"`
Cluster string `yaml:"cluster" json:"cluster,omitempty"`
Expand All @@ -53,7 +52,7 @@ type ConfigCenterConfig struct {
Password string `yaml:"password" json:"password,omitempty"`
LogDir string `yaml:"log_dir" json:"log_dir,omitempty"`
ConfigFile string `default:"dubbo.properties" yaml:"config_file" json:"config_file,omitempty"`
Namespace string `default:"dubbo" yaml:"namespace" json:"namespace,omitempty"`
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
AppConfigFile string `default:"dubbo.properties" yaml:"app_config_file" json:"app_config_file,omitempty"`
AppID string `default:"dubbo" yaml:"app_id" json:"app_id,omitempty"`
TimeoutStr string `yaml:"timeout" json:"timeout,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions config_center/dynamic_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (
// DynamicConfiguration
// ////////////////////////////////////////
const (
// DEFAULT_GROUP: default group
// DEFAULT_GROUP default group
DEFAULT_GROUP = "dubbo"
// DEFAULT_CONFIG_TIMEOUT: default config timeout
DEFAULT_CONFIG_TIMEOUT = "10s"
// ZK_DEFAULT_GROUP default group of zk
ZK_DEFAULT_GROUP = "dubbo"
)

// DynamicConfiguration for modify listener and get properties file
Expand Down
9 changes: 3 additions & 6 deletions config_center/nacos/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/config_center"
"github.com/apache/dubbo-go/config_center/parser"
Expand All @@ -49,7 +48,6 @@ const (
type nacosDynamicConfiguration struct {
config_center.BaseDynamicConfiguration
url *common.URL
rootPath string
wg sync.WaitGroup
cltLock sync.Mutex
done chan struct{}
Expand All @@ -60,13 +58,12 @@ type nacosDynamicConfiguration struct {

func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, error) {
c := &nacosDynamicConfiguration{
rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
url: url,
done: make(chan struct{}),
url: url,
done: make(chan struct{}),
}
err := ValidateNacosClient(c)
if err != nil {
logger.Errorf("nacos client start error ,error message is %v", err)
logger.Errorf("nacos client start error, error message is %v", err)
return nil, err
}
c.wg.Add(1)
Expand Down
6 changes: 3 additions & 3 deletions config_center/zookeeper/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ type zookeeperDynamicConfiguration struct {
func newZookeeperDynamicConfiguration(url *common.URL) (*zookeeperDynamicConfiguration, error) {
c := &zookeeperDynamicConfiguration{
url: url,
rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.ZK_DEFAULT_GROUP) + "/config",
}
err := zookeeper.ValidateZookeeperClient(c, ZkClient)
if err != nil {
logger.Errorf("zookeeper client start error ,error message is %v", err)
logger.Errorf("zookeeper client start error, error message is %v", err)
return nil, err
}
c.wg.Add(1)
Expand Down Expand Up @@ -227,7 +227,7 @@ func (c *zookeeperDynamicConfiguration) getPath(key string, group string) string

func (c *zookeeperDynamicConfiguration) buildPath(group string) string {
if len(group) == 0 {
group = config_center.DEFAULT_GROUP
group = config_center.ZK_DEFAULT_GROUP
}
return c.rootPath + pathSeparator + group
}
2 changes: 1 addition & 1 deletion remoting/nacos/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func GetNacosConfig(url *common.URL) ([]nacosConstant.ServerConfig, nacosConstan
clientConfig := nacosConstant.ClientConfig{
TimeoutMs: uint64(int32(timeout / time.Millisecond)),
BeatInterval: url.GetParamInt(constant.NACOS_BEAT_INTERVAL_KEY, 5000),
NamespaceId: url.GetParam(constant.NACOS_NAMESPACE_ID, ""),
NamespaceId: url.GetParam(constant.CONFIG_NAMESPACE_KEY, ""),
AppName: url.GetParam(constant.NACOS_APP_NAME_KEY, ""),
Endpoint: url.GetParam(constant.NACOS_ENDPOINT, ""),
RegionId: url.GetParam(constant.NACOS_REGION_ID_KEY, ""),
Expand Down

0 comments on commit 5a90f47

Please sign in to comment.