handle Loader.Load return value error

This commit is contained in:
Allenxuxu
2020-01-19 16:31:02 +08:00
parent 1983d607f3
commit a82fd19209
3 changed files with 25 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ type watcher struct {
value reader.Value
}
func newConfig(opts ...Option) Config {
func newConfig(opts ...Option) (Config, error) {
options := Options{
Loader: memory.NewLoader(),
Reader: json.NewReader(),
@@ -40,7 +40,10 @@ func newConfig(opts ...Option) Config {
o(&options)
}
options.Loader.Load(options.Source...)
if err := options.Loader.Load(options.Source...); err != nil {
return nil, err
}
snap, _ := options.Loader.Snapshot()
vals, _ := options.Reader.Values(snap.ChangeSet)
@@ -53,7 +56,7 @@ func newConfig(opts ...Option) Config {
go c.run()
return c
return c, nil
}
func (c *config) run() {