config: minor changes to split config and watcher files

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-08-04 15:04:18 +03:00
parent 8762cb5a71
commit 0112c44d7d
4 changed files with 123 additions and 5 deletions

15
file.go
View File

@@ -134,6 +134,21 @@ func (c *fileConfig) Name() string {
return c.opts.Name
}
func (c *fileConfig) Watch(ctx context.Context, opts ...config.WatchOption) (config.Watcher, error) {
w := &fileWatcher{
path: c.path,
opts: c.opts,
wopts: config.NewWatchOptions(opts...),
done: make(chan struct{}),
vchan: make(chan map[string]interface{}),
echan: make(chan error),
}
go w.run()
return w, nil
}
func NewConfig(opts ...config.Option) config.Config {
options := config.NewOptions(opts...)
if len(options.StructTag) == 0 {