diff --git a/config/interfaces/config_post_processor.go b/config/interfaces/config_post_processor.go index d028e29286..53dd71780f 100644 --- a/config/interfaces/config_post_processor.go +++ b/config/interfaces/config_post_processor.go @@ -17,14 +17,16 @@ package interfaces -import "net/url" +import ( + "github.com/apache/dubbo-go/common" +) // ConfigPostProcessor is an extension to give users a chance to customize configs against ReferenceConfig and // ServiceConfig during deployment time. type ConfigPostProcessor interface { // PostProcessReferenceConfig customizes ReferenceConfig's params. - PostProcessReferenceConfig(url.Values) + PostProcessReferenceConfig(*common.URL) // PostProcessServiceConfig customizes ServiceConfig's params. - PostProcessServiceConfig(url.Values) + PostProcessServiceConfig(*common.URL) } diff --git a/config/reference_config.go b/config/reference_config.go index ea0da54017..d6096e5d90 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -91,19 +91,18 @@ func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error // Refer ... func (c *ReferenceConfig) Refer(_ interface{}) { - urlMap := c.getUrlMap() - c.postProcessConfig(urlMap) - cfgURL := common.NewURLWithOptions( common.WithPath(c.InterfaceName), common.WithProtocol(c.Protocol), - common.WithParams(urlMap), + common.WithParams(c.getUrlMap()), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), ) if c.ForceTag { cfgURL.AddParam(constant.ForceUseTag, "true") } + c.postProcessConfig(cfgURL) + if c.Url != "" { // 1. user specified URL, could be peer-to-peer address, or register center's address. urlStrings := gxstrings.RegSplit(c.Url, "\\s*[;]+\\s*") @@ -254,8 +253,8 @@ func (c *ReferenceConfig) GenericLoad(id string) { } // postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. -func (c *ReferenceConfig) postProcessConfig(values url.Values) { +func (c *ReferenceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { - p.PostProcessReferenceConfig(values) + p.PostProcessReferenceConfig(url) } } diff --git a/config/service_config.go b/config/service_config.go index 987bf0a776..7efbef708f 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -159,10 +159,7 @@ func (c *ServiceConfig) Export() error { } regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) - urlMap := c.getUrlMap() - c.postProcessConfig(urlMap) - protocolConfigs := loadProtocol(c.Protocol, c.Protocols) if len(protocolConfigs) == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.InterfaceName, c.Protocol) @@ -201,6 +198,8 @@ func (c *ServiceConfig) Export() error { ivkURL.AddParam(constant.Tagkey, c.Tag) } + c.postProcessConfig(ivkURL) + if len(regUrls) > 0 { c.cacheMutex.Lock() if c.cacheProtocol == nil { @@ -337,8 +336,8 @@ func (c *ServiceConfig) GetExportedUrls() []*common.URL { } // postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig. -func (c *ServiceConfig) postProcessConfig(values url.Values) { +func (c *ServiceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { - p.PostProcessServiceConfig(values) + p.PostProcessServiceConfig(url) } }