From 96831bf3a88e1492f4f8717c90b4274aba8a3e96 Mon Sep 17 00:00:00 2001 From: tian Date: Mon, 22 Jul 2019 18:31:31 +0800 Subject: [PATCH] give app,version,service param --- go.mod | 6 +----- sources/configcenter/configcenter.go | 12 +++++------- .../envconfigurationsource_test.go | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index fab64425..e1281ed9 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,12 @@ module github.com/go-chassis/go-archaius require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.7 - github.com/go-chassis/go-chassis-config v0.8.0 + github.com/go-chassis/go-chassis-config v0.9.0 github.com/go-mesh/openlogging v1.0.0 github.com/gorilla/websocket v1.4.0 - github.com/pkg/errors v0.8.1 // indirect github.com/spf13/cast v1.2.0 github.com/stretchr/testify v1.3.0 - golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87 // indirect - gopkg.in/go-playground/assert.v1 v1.2.1 gopkg.in/yaml.v2 v2.2.1 ) diff --git a/sources/configcenter/configcenter.go b/sources/configcenter/configcenter.go index 21732168..278cfe0b 100755 --- a/sources/configcenter/configcenter.go +++ b/sources/configcenter/configcenter.go @@ -43,10 +43,6 @@ var ( //Handler handles configs from config center type Handler struct { - Service string - Version string - App string - Env string cc config.Client dynamicConfigHandler *DynamicConfigHandler dimensionInfoMap map[string]string @@ -67,7 +63,6 @@ var ConfigCenterConfig *Handler //NewConfigCenterSource initializes all components of configuration center func NewConfigCenterSource(cc config.Client, refreshMode, refreshInterval int) core.ConfigSource { - if ConfigCenterConfig == nil { ConfigCenterConfig = new(Handler) ConfigCenterConfig.priority = configCenterSourcePriority @@ -152,12 +147,15 @@ func (cfgSrcHandler *Handler) refreshConfigurations(dimensionInfo string) error ) if dimensionInfo == "" { - config, err = cfgSrcHandler.cc.PullConfigs(cfgSrcHandler.Service, - cfgSrcHandler.Version, cfgSrcHandler.App, cfgSrcHandler.Env) + config, err = cfgSrcHandler.cc.PullConfigs(cfgSrcHandler.cc.Options().ServiceName, + cfgSrcHandler.cc.Options().Version, cfgSrcHandler.cc.Options().App, cfgSrcHandler.cc.Options().Env) if err != nil { openlogging.GetLogger().Warnf("Failed to pull configurations from config center server", err) //Warn return err } + openlogging.Debug("pull configs", openlogging.WithTags(openlogging.Tags{ + "config": config, + })) //Populate the events based on the changed value between current config and newly received Config events, err = cfgSrcHandler.populateEvents(config) } else { diff --git a/sources/enviromentvariable-source/envconfigurationsource_test.go b/sources/enviromentvariable-source/envconfigurationsource_test.go index 6f4b309c..3cefed92 100755 --- a/sources/enviromentvariable-source/envconfigurationsource_test.go +++ b/sources/enviromentvariable-source/envconfigurationsource_test.go @@ -21,9 +21,9 @@ package envconfigsource import ( "github.com/go-chassis/go-archaius/core" - "gopkg.in/go-playground/assert.v1" "os" "testing" + "github.com/stretchr/testify/assert" ) type TestDynamicConfigHandler struct{}