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

laurence 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 cb29fbc  fix: add get dynamic configuration api (#1439)
cb29fbc is described below

commit cb29fbcb6a2e853bc4f9b138b8cdee290a6b2541
Author: Laurence <[email protected]>
AuthorDate: Sat Sep 4 19:54:17 2021 +0800

    fix: add get dynamic configuration api (#1439)
---
 config/config_center_config.go         | 12 ++++++++++++
 config_center/dynamic_configuration.go |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/config/config_center_config.go b/config/config_center_config.go
index 84a10dc..479bf71 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -176,6 +176,18 @@ func startConfigCenter(rc *RootConfig) error {
        return nil
 }
 
+func (c *CenterConfig) GetDynamicConfiguration() 
(config_center.DynamicConfiguration, error) {
+       configCenterUrl, err := c.toURL()
+       if err != nil {
+               return nil, err
+       }
+       factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol)
+       if factory == nil {
+               return nil, errors.New("get config center factory failed")
+       }
+       return factory.GetDynamicConfiguration(configCenterUrl)
+}
+
 func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) 
(string, error) {
        factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol)
        if factory == nil {
diff --git a/config_center/dynamic_configuration.go 
b/config_center/dynamic_configuration.go
index 069594d..447342e 100644
--- a/config_center/dynamic_configuration.go
+++ b/config_center/dynamic_configuration.go
@@ -56,6 +56,8 @@ type DynamicConfiguration interface {
        GetInternalProperty(string, ...Option) (string, error)
 
        // PublishConfig will publish the config with the (key, group, value) 
pair
+       // for zk: path is /$(group)/config/$(key) -> value
+       // for nacos: group, key -> value
        PublishConfig(string, string, string) error
 
        // RemoveConfig will remove the config white the (key, group) pair

Reply via email to