diff --git a/config/base_config.go b/config/base_config.go index 3602c17508f26480b115dd45f46685adf86c718e..22a0832731daff6c9957d4913a3784c9b268b11f 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -29,7 +29,6 @@ import ( ) import ( - "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/config" "github.com/apache/dubbo-go/common/logger" ) @@ -69,21 +68,6 @@ func (c *BaseConfig) GetRemoteConfig(name string) (config *RemoteConfig, ok bool return } -func (c *BaseConfig) toConfigCenterURL() (common.URL, error) { - rc, ok := GetBaseConfig().GetRemoteConfig(baseConfig.ConfigCenterConfig.RemoteRef) - - if !ok { - return common.URL{}, perrors.New("Could not find out the remote ref config, name: " + name) - } - - return common.NewURL(rc.Address, - common.WithUsername(rc.Username), - common.WithPassword(rc.Password), - common.WithLocation(rc.Address), - common.WithProtocol(baseConfig.ConfigCenterConfig.Protocol), - ) -} - func getKeyPrefix(val reflect.Value) []string { var ( prefix string diff --git a/config/config_center_config.go b/config/config_center_config.go index 514e2d9a0e3acec356228dc495ba7a137016931d..e50fabd5558a84274a87afe6f78227b902cd10a9 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -96,7 +96,15 @@ func (b *configCenter) toURL(baseConfig BaseConfig) (common.URL, error) { return common.NewURL(baseConfig.ConfigCenterConfig.Address, common.WithProtocol(baseConfig.ConfigCenterConfig.Protocol), common.WithParams(baseConfig.ConfigCenterConfig.GetUrlMap())) } - newURL, err := baseConfig.toConfigCenterURL() + + remoteRef := baseConfig.ConfigCenterConfig.RemoteRef + rc, ok := GetBaseConfig().GetRemoteConfig(remoteRef) + + if !ok { + return common.URL{}, perrors.New("Could not find out the remote ref config, name: " + remoteRef) + } + + newURL, err := rc.toURL(baseConfig.ConfigCenterConfig.Protocol) if err == nil { newURL.SetParams(baseConfig.ConfigCenterConfig.GetUrlMap()) } diff --git a/config/remote_config.go b/config/remote_config.go index 5e0330c571715d99e63688ee944c61f8e48117bb..618313d7dc6374f291eb51d20cd38861762ff4a1 100644 --- a/config/remote_config.go +++ b/config/remote_config.go @@ -18,6 +18,7 @@ package config import ( + "github.com/apache/dubbo-go/common" "time" ) @@ -56,3 +57,12 @@ func (rc *RemoteConfig) GetParam(key string, def string) string { } return param } + +func (rc *RemoteConfig) toURL(protocol string) (common.URL, error) { + return common.NewURL(rc.Address, + common.WithUsername(rc.Username), + common.WithPassword(rc.Password), + common.WithLocation(rc.Address), + common.WithProtocol(protocol), + ) +}