Skip to content
Snippets Groups Projects
Commit d36e789b authored by Ian Luo's avatar Ian Luo
Browse files

break import cycle

parent 3f949237
No related branches found
No related tags found
No related merge requests found
......@@ -17,25 +17,27 @@
package extension
import "github.com/apache/dubbo-go/config"
import (
"github.com/apache/dubbo-go/config/interfaces"
)
var (
processors = make(map[string]config.ConfigPostProcessor)
processors = make(map[string]interfaces.ConfigPostProcessor)
)
// SetConfigPostProcessor registers a ConfigPostProcessor with the given name.
func SetConfigPostProcessor(name string, processor config.ConfigPostProcessor) {
func SetConfigPostProcessor(name string, processor interfaces.ConfigPostProcessor) {
processors[name] = processor
}
// GetConfigPostProcessor finds a ConfigPostProcessor by name.
func GetConfigPostProcessor(name string) config.ConfigPostProcessor {
func GetConfigPostProcessor(name string) interfaces.ConfigPostProcessor {
return processors[name]
}
// GetConfigPostProcessors returns all registered instances of ConfigPostProcessor.
func GetConfigPostProcessors() []config.ConfigPostProcessor {
ret := make([]config.ConfigPostProcessor, 0, len(processors))
func GetConfigPostProcessors() []interfaces.ConfigPostProcessor {
ret := make([]interfaces.ConfigPostProcessor, 0, len(processors))
for _, v := range processors {
ret = append(ret, v)
}
......
......@@ -15,14 +15,14 @@
* limitations under the License.
*/
package config
package interfaces
// 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
PostProcessReferenceConfig(rc *ReferenceConfig)
// PostProcessReferenceConfig customizes ReferenceConfig's params
PostProcessReferenceConfig(params *map[string]string)
// PostProcessServiceConfig customizes ServiceConfig
PostProcessServiceConfig(sc *ServiceConfig)
// PostProcessServiceConfig customizes ServiceConfig's params
PostProcessServiceConfig(params *map[string]string)
}
......@@ -254,6 +254,6 @@ func (c *ReferenceConfig) GenericLoad(id string) {
// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig.
func (c *ReferenceConfig) postProcessConfig() {
for _, p := range extension.GetConfigPostProcessors() {
p.PostProcessReferenceConfig(c)
p.PostProcessReferenceConfig(&c.Params)
}
}
......@@ -337,6 +337,6 @@ func (c *ServiceConfig) GetExportedUrls() []*common.URL {
// postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig.
func (c *ServiceConfig) postProcessConfig() {
for _, p := range extension.GetConfigPostProcessors() {
p.PostProcessServiceConfig(c)
p.PostProcessServiceConfig(&c.Params)
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment