config: add Save/Load options

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-06-20 23:57:13 +03:00
parent 598dddc476
commit 2a548634fd
3 changed files with 67 additions and 10 deletions

View File

@@ -20,25 +20,27 @@ var (
// Config is an interface abstraction for dynamic configuration
type Config interface {
// Name returns name of config
Name() string
// Init the config
Init(opts ...Option) error
// Options in the config
Options() Options
// Load config from sources
Load(context.Context) error
Load(context.Context, ...LoadOption) error
// Save config to sources
Save(context.Context) error
Save(context.Context, ...SaveOption) error
// Watch a value for changes
// Watch(interface{}) (Watcher, error)
//Watch(context.Context) (Watcher, error)
// String returns config type name
String() string
}
// Watcher is the config watcher
// type Watcher interface {
// Next() (, error)
// Stop() error
// }
type Watcher interface {
// Next() (, error)
Stop() error
}
// Load loads config from config sources
func Load(ctx context.Context, cs ...Config) error {