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/08/26 11:37:14 UTC
[dubbo-go] branch config-enhance updated: fix apollo config center
parse bug (#1411)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/config-enhance by this push:
new da318d3 fix apollo config center parse bug (#1411)
da318d3 is described below
commit da318d3fccf0beb21071cff1a90c734770c69af1
Author: Baster <ja...@gmail.com>
AuthorDate: Thu Aug 26 19:37:09 2021 +0800
fix apollo config center parse bug (#1411)
Co-authored-by: zengfanwei <ze...@yalla.live>
---
config/config_center_config.go | 2 ++
config_center/apollo/impl.go | 11 +++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/config/config_center_config.go b/config/config_center_config.go
index f83d32b..4de8098 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -170,6 +170,7 @@ func startConfigCenter(rc *RootConfig) error {
rc, koanf.UnmarshalConf{Tag: "yaml"}); err != nil {
return err
}
+
rc.refresh = false
rc.ConfigCenter = nil
return nil
@@ -184,6 +185,7 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string,
}
envInstance := conf.GetEnvInstance()
envInstance.SetDynamicConfiguration(dynamicConfig)
+
return dynamicConfig.GetProperties(c.DataId, config_center.WithGroup(c.Group))
//if err != nil {
// logger.Errorf("Get config content in dynamic configuration error , error message is %v", err)
diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go
index 4c1f107..a088d1a 100644
--- a/config_center/apollo/impl.go
+++ b/config_center/apollo/impl.go
@@ -103,7 +103,7 @@ func (c *apolloConfiguration) RemoveListener(key string, listener cc.Configurati
}
func getProperties(namespace string) string {
- return getNamespaceName(namespace, agolloConstant.Properties)
+ return getNamespaceName(namespace, agolloConstant.YAML)
}
func getNamespaceName(namespace string, configFileFormat agolloConstant.ConfigFileFormat) string {
@@ -137,11 +137,18 @@ func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (stri
* when group is not null, we are getting startup configs(config file) from ShutdownConfig Center, for example:
* key=dubbo.propertie
*/
+ if key == "" {
+ key = c.appConf.NamespaceName
+ }
tmpConfig := agollo.GetConfig(key)
if tmpConfig == nil {
return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key))
}
- return tmpConfig.GetContent(), nil
+
+ content := tmpConfig.GetContent()
+ b := []byte(content)
+ content = string(b[8:]) //remove defalut content= prefix
+ return content, nil
}
func (c *apolloConfiguration) getAddressWithProtocolPrefix(url *common.URL) string {