Documentation ¶
Overview ¶
Package config is an interface for dynamic configuration.
Index ¶
- Variables
- func AppendServiceTag(tags ...string)
- func Byte() []byte
- func Close() error
- func Fields() *field.Fields
- func Get(path ...string) reader.Value
- func Load(source ...source.Source) error
- func Scan(val Config) error
- func ServiceName() string
- func ServiceTag() []string
- func ServiceVersion() string
- func SetServiceTag(tags ...string)
- func Sync() error
- func Validate(val Config) error
- type Config
- type Configurator
- type Option
- type Options
- type Source
- type Watcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Default Config Manager Default = NewConfig( WithValidator(playground.New("zh")), ) )
Functions ¶
func AppendServiceTag ¶ added in v1.0.0
func AppendServiceTag(tags ...string)
func ServiceName ¶ added in v1.0.0
func ServiceName() string
func ServiceTag ¶ added in v1.0.0
func ServiceTag() []string
func ServiceVersion ¶ added in v1.0.0
func ServiceVersion() string
func SetServiceTag ¶ added in v1.0.0
func SetServiceTag(tags ...string)
Types ¶
type Config ¶ added in v1.0.0
type Config interface {
Path() string
}
Config is set of config fields. "." is a level splitter. For example:
father.child
It means that config data's struct same as this.
{ "father": { "child": {xxx} } }
type Configurator ¶
type Configurator interface { // Load config sources Load(source ...source.Source) error // Sync force a source change set sync Sync() error // Close stop the config loader/watcher Close() error // Bytes get merged config data Bytes() []byte // Scan to val Scan(val Config) error // Validate val Validate(val Config) error // Watch field change Watch(path ...string) (Watcher, error) // Get value through field Get(path ...string) reader.Value // Fields return scanned fields Fields() *field.Fields }
Configurator is an interface abstraction for dynamic configuration
type Option ¶
type Option func(o *Options)
func WithLoader ¶
WithLoader sets the loader for manager config
func WithSource ¶
WithSource appends a source to list of sources
func WithValidator ¶ added in v1.1.1
WithValidator sets the loader for manager config
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package loader manages loading from multiple sources
|
Package loader manages loading from multiple sources |
Package reader parses change sets and provides config values
|
Package reader parses change sets and provides config values |
Package source is the interface for sources
|
Package source is the interface for sources |
file
Package file is a file source.
|
Package file is a file source. |
Click to show internal directories.
Click to hide internal directories.