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

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new d19b761da refactor: remove config package from polaris and 
config_center (#3210)
d19b761da is described below

commit d19b761da51004e22aad4d2542eaae70b5eb33bf
Author: zbchi <[email protected]>
AuthorDate: Sun Mar 1 23:54:25 2026 +0800

    refactor: remove config package from polaris and config_center (#3210)
    
    * refactor: remove config package from polaris and config_center
    
    * use constant key
    
    * Update config_center/apollo/impl_test.go
    
    Co-authored-by: Copilot <[email protected]>
    
    * Update filter/polaris/limit/limiter.go
    
    Co-authored-by: Copilot <[email protected]>
    
    * chore: trigger CI to recheck tests
    
    * fix lint
    
    * use constant.ApplicationConfigPrefix
    
    * refactor: use constants for config center parameters
    
    * remove redundant registry config check
    
    ---------
    
    Co-authored-by: Copilot <[email protected]>
---
 common/constant/key.go            |  1 +
 config_center/apollo/impl_test.go | 49 +++++++++++++++++++++------------------
 config_center/zookeeper/impl.go   |  6 ++---
 filter/polaris/limit/limiter.go   | 18 +++-----------
 4 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/common/constant/key.go b/common/constant/key.go
index 5cc333f20..d2dd1ebdf 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -247,6 +247,7 @@ const (
        ConfigSecretKey           = "config-center.secret"
        ConfigBackupConfigKey     = "config-center.isBackupConfig"
        ConfigBackupConfigPathKey = "config-center.backupConfigPath"
+       ConfigRootPathParamKey    = "dubbo.config-center.root-path"
 )
 
 const (
diff --git a/config_center/apollo/impl_test.go 
b/config_center/apollo/impl_test.go
index 606122f7e..464e67794 100644
--- a/config_center/apollo/impl_test.go
+++ b/config_center/apollo/impl_test.go
@@ -22,13 +22,14 @@ import (
        "fmt"
        "net/http"
        "net/http/httptest"
+       "net/url"
        "strings"
        "sync"
        "testing"
 )
 
 import (
-       "github.com/apolloconfig/agollo/v4/constant"
+       apolloconstant "github.com/apolloconfig/agollo/v4/constant"
        "github.com/apolloconfig/agollo/v4/extension"
 
        "github.com/knadh/koanf"
@@ -44,8 +45,9 @@ import (
 
 import (
        "dubbo.apache.org/dubbo-go/v3/common"
-       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
        "dubbo.apache.org/dubbo-go/v3/config_center"
+       "dubbo.apache.org/dubbo-go/v3/global"
        "dubbo.apache.org/dubbo-go/v3/remoting"
 )
 
@@ -147,56 +149,57 @@ func TestGetConfig(t *testing.T) {
        configuration := initMockApollo(t)
        configs, err := configuration.GetProperties(mockNamespace, 
config_center.WithGroup("dubbo"))
        require.NoError(t, err)
+
        koan := koanf.New(".")
        err = koan.Load(rawbytes.Provider([]byte(configs)), yaml.Parser())
        require.NoError(t, err)
-       rc := &config.RootConfig{}
-       err = koan.UnmarshalWithConf(rc.Prefix(), rc, koanf.UnmarshalConf{Tag: 
"yaml"})
+
+       appCfg := &global.ApplicationConfig{}
+       err = koan.UnmarshalWithConf(constant.ApplicationConfigPrefix, appCfg, 
koanf.UnmarshalConf{Tag: "yaml"})
        require.NoError(t, err)
 
-       assert.Equal(t, "demo-server", rc.Application.Name)
+       assert.Equal(t, "demo-server", appCfg.Name)
 }
 
 func TestGetJsonConfig(t *testing.T) {
        configuration := initMockApollo(t)
        configs, err := configuration.GetProperties(mockJsonNamespace, 
config_center.WithGroup("dubbo"))
        require.NoError(t, err)
+
        koan := koanf.New(":")
        err = koan.Load(rawbytes.Provider([]byte(configs)), json.Parser())
        require.NoError(t, err)
-       rc := &config.RootConfig{}
-       err = koan.UnmarshalWithConf(rc.Prefix(), rc, koanf.UnmarshalConf{Tag: 
"json"})
+
+       appCfg := &global.ApplicationConfig{}
+       err = koan.UnmarshalWithConf("dubbo:application", appCfg, 
koanf.UnmarshalConf{Tag: "json"})
        require.NoError(t, err)
 
-       assert.Equal(t, "demo-server", rc.Application.Name)
+       assert.Equal(t, "demo-server", appCfg.Name)
 }
 
 func TestGetConfigItem(t *testing.T) {
        configuration := initMockApollo(t)
-       appName, err := 
configuration.GetInternalProperty("dubbo.application.name")
+       appName, err := 
configuration.GetInternalProperty(constant.ApplicationConfigPrefix + ".name")
        require.NoError(t, err)
        assert.Equal(t, "demo-server", appName)
 }
 
 func initMockApollo(t *testing.T) *apolloConfiguration {
        // Register the YAML format parser with concurrent safety.
-       extension.AddFormatParser(constant.YAML, &Parser{})
-       extension.AddFormatParser(constant.YML, &Parser{})
-       c := &config.RootConfig{ConfigCenter: &config.CenterConfig{
-               Protocol:  "apollo",
-               Address:   "localhost:8080",
-               AppID:     "testApplication_yang",
-               Cluster:   "dev",
-               Namespace: "mockDubbogo.yaml",
-               Params: map[string]string{
-                       "config-center.isBackupConfig": "false",
-               },
-       }}
+       extension.AddFormatParser(apolloconstant.YAML, &Parser{})
+       extension.AddFormatParser(apolloconstant.YML, &Parser{})
+
+       params := url.Values{}
+       params.Set(constant.ConfigNamespaceKey, "mockDubbogo.yaml")
+       params.Set(constant.ConfigAppIDKey, "testApplication_yang")
+       params.Set(constant.ConfigClusterKey, "dev")
+       params.Set(constant.ConfigBackupConfigKey, "false")
+
        apollo := initApollo()
        apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo")
-       url, err := common.NewURL(apolloUrl, 
common.WithParams(c.ConfigCenter.GetUrlMap()))
+       apolloCfgURL, err := common.NewURL(apolloUrl, common.WithParams(params))
        require.NoError(t, err)
-       configuration, err := newApolloConfiguration(url)
+       configuration, err := newApolloConfiguration(apolloCfgURL)
        require.NoError(t, err)
        return configuration
 }
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index 7ab134aac..c663faa61 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -66,10 +66,10 @@ type zookeeperDynamicConfiguration struct {
 }
 
 func newZookeeperDynamicConfiguration(url *common.URL) 
(*zookeeperDynamicConfiguration, error) {
+       rootPath := url.GetParam(constant.ConfigRootPathParamKey, 
"/dubbo/config")
        c := &zookeeperDynamicConfiguration{
-               url: url,
-               // TODO adapt config center config
-               rootPath: "/dubbo/config",
+               url:      url,
+               rootPath: rootPath,
        }
        logger.Infof("[Zookeeper ConfigCenter] New Zookeeper ConfigCenter with 
Configuration: %+v, url = %+v", c, c.GetURL())
        if v := url.GetParam("base64", ""); v != "" {
diff --git a/filter/polaris/limit/limiter.go b/filter/polaris/limit/limiter.go
index 535e7d3e8..e7ee535b7 100644
--- a/filter/polaris/limit/limiter.go
+++ b/filter/polaris/limit/limiter.go
@@ -35,7 +35,6 @@ import (
 import (
        "dubbo.apache.org/dubbo-go/v3/common"
        "dubbo.apache.org/dubbo-go/v3/common/constant"
-       "dubbo.apache.org/dubbo-go/v3/config"
        "dubbo.apache.org/dubbo-go/v3/protocol/base"
        remotingpolaris "dubbo.apache.org/dubbo-go/v3/remoting/polaris"
        "dubbo.apache.org/dubbo-go/v3/remoting/polaris/parser"
@@ -78,27 +77,16 @@ func (pl *polarisTpsLimiter) buildQuotaRequest(url 
*common.URL, invocation base.
        ns := remotingpolaris.GetNamespace()
        applicationMode := false
 
-       // TODO: only for compatibility with old config, able to directly 
remove after config is deleted
-       for _, item := range config.GetRootConfig().Registries {
-               if item.Protocol == constant.PolarisKey {
-                       applicationMode = item.RegistryType == 
constant.ServiceKey
-               }
-       }
-
        if url.GetParam(constant.RegistryKey, "") == constant.PolarisKey {
-               if registryType := url.GetParam(constant.RegistryTypeKey, ""); 
registryType != "" {
-                       applicationMode = registryType == constant.ServiceKey
+               if registryType := url.GetParam(constant.RegistryTypeKey, ""); 
registryType == constant.ServiceKey {
+                       applicationMode = true
                }
        }
 
        svc := url.Interface()
        method := invocation.MethodName()
        if applicationMode {
-               // TODO: only for compatibility with old config, able to 
directly remove after config is deleted
-               svc = config.GetApplicationConfig().Name
-               if applicationKey := url.GetParam(constant.ApplicationKey, ""); 
applicationKey != "" {
-                       svc = applicationKey
-               }
+               svc = url.GetParam(constant.ApplicationKey, svc)
                method = url.Interface() + "/" + invocation.MethodName()
        }
 

Reply via email to