micro/config/noop.go
Vasiliy Tolstov 5279c2aa0f
config package rework (#9)
* change config interface
* reuse codec
* allow to modify next config based on values in current config via BeforeLoad

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-12-04 02:28:45 +03:00

37 lines
626 B
Go

// Package config is an interface for dynamic configuration.
package config
import "context"
type noopConfig struct {
opts Options
}
func (c *noopConfig) Init(opts ...Option) error {
for _, o := range opts {
o(&c.opts)
}
return nil
}
func (c *noopConfig) Load(ctx context.Context) error {
return nil
}
func (c *noopConfig) Save(ctx context.Context) error {
return nil
}
func (c *noopConfig) Options() Options {
return c.opts
}
func (c *noopConfig) String() string {
return "noop"
}
// NewConfig returns new noop config
func NewConfig(opts ...Option) Config {
return &noopConfig{opts: NewOptions(opts...)}
}