diff --git a/config/config.go b/config/config.go index 77a9fdc1..a41a7881 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,6 @@ import ( "github.com/micro/go-micro/v3/config/loader" "github.com/micro/go-micro/v3/config/reader" "github.com/micro/go-micro/v3/config/source" - "github.com/micro/go-micro/v3/config/source/file" ) // Config is an interface abstraction for dynamic configuration @@ -45,54 +44,7 @@ type Options struct { type Option func(o *Options) -var ( - // Default Config Manager - DefaultConfig, _ = NewConfig() -) - // NewConfig returns new config func NewConfig(opts ...Option) (Config, error) { return newConfig(opts...) } - -// Return config as raw json -func Bytes() []byte { - return DefaultConfig.Bytes() -} - -// Return config as a map -func Map() map[string]interface{} { - return DefaultConfig.Map() -} - -// Scan values to a go type -func Scan(v interface{}) error { - return DefaultConfig.Scan(v) -} - -// Force a source changeset sync -func Sync() error { - return DefaultConfig.Sync() -} - -// Get a value from the config -func Get(path ...string) reader.Value { - return DefaultConfig.Get(path...) -} - -// Load config sources -func Load(source ...source.Source) error { - return DefaultConfig.Load(source...) -} - -// Watch a value for changes -func Watch(path ...string) (Watcher, error) { - return DefaultConfig.Watch(path...) -} - -// LoadFile is short hand for creating a file source and loading it -func LoadFile(path string) error { - return Load(file.NewSource( - file.WithPath(path), - )) -} diff --git a/config/default.go b/config/default.go index bd946f03..41d357d3 100644 --- a/config/default.go +++ b/config/default.go @@ -33,9 +33,11 @@ type watcher struct { func newConfig(opts ...Option) (Config, error) { var c config - c.Init(opts...) - go c.run() + if err := c.Init(opts...); err != nil { + return nil, err + } + go c.run() return &c, nil }