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

liujun 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 6c26c9912 feat: implement RemoveConfig API for nacos and zookeeper 
(#2234)
6c26c9912 is described below

commit 6c26c99122cc78d4dc32eb2f6b50f7c4c8bbba4a
Author: Yixiang Zhao <[email protected]>
AuthorDate: Sat Mar 25 11:22:26 2023 +0800

    feat: implement RemoveConfig API for nacos and zookeeper (#2234)
---
 config_center/nacos/impl.go     | 16 ++++++++++++++++
 config_center/zookeeper/impl.go | 10 ++++++++++
 2 files changed, 26 insertions(+)

diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index 1a4ffa8bb..50209ddc1 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -123,6 +123,22 @@ func (n *nacosDynamicConfiguration) PublishConfig(key 
string, group string, valu
        return nil
 }
 
+// RemoveConfig will remove the config with the (key, group) pair
+func (n *nacosDynamicConfiguration) RemoveConfig(key string, group string) 
error {
+       group = n.resolvedGroup(group)
+       ok, err := n.client.Client().DeleteConfig(vo.ConfigParam{
+               DataId: key,
+               Group:  group,
+       })
+       if err != nil {
+               return perrors.WithStack(err)
+       }
+       if !ok {
+               return perrors.New("remove config from Nacos failed")
+       }
+       return nil
+}
+
 // GetConfigKeysByGroup will return all keys with the group
 func (n *nacosDynamicConfiguration) GetConfigKeysByGroup(group string) 
(*gxset.HashSet, error) {
        group = n.resolvedGroup(group)
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index 538058cf1..e22f7ad21 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -171,6 +171,16 @@ func (c *zookeeperDynamicConfiguration) PublishConfig(key 
string, group string,
        return nil
 }
 
+// RemoveConfig will remove the config with the (key, group) pair
+func (c *zookeeperDynamicConfiguration) RemoveConfig(key string, group string) 
error {
+       path := c.getPath(key, group)
+       err := c.client.Delete(path)
+       if err != nil {
+               return perrors.WithStack(err)
+       }
+       return nil
+}
+
 // GetConfigKeysByGroup will return all keys with the group
 func (c *zookeeperDynamicConfiguration) GetConfigKeysByGroup(group string) 
(*gxset.HashSet, error) {
        path := c.getPath("", group)

Reply via email to