Documentation ¶
Overview ¶
Package config is an interface for dynamic configuration.
Index ¶
- Variables
- func ClassicSource(filePath, username, password, address string) []source.Source
- func Close() error
- func EtcdSource(prefix, username, password, address string) []source.Source
- func Get(field *Field) reader.Value
- func GetBool(field *Field) bool
- func GetBoxName() string
- func GetDuration(field *Field) time.Duration
- func GetFloat64(field *Field) float64
- func GetInt(field *Field) int
- func GetString(field *Field) string
- func GetStringMap(field *Field) map[string]string
- func GetStringSlice(field *Field) []string
- func GetTraceBizId() string
- func GetTraceReqId() string
- func GetTraceSpanId() string
- func GetTraceUid() string
- func GetUint(field *Field) uint
- func Load(source ...source.Source) error
- func Mount(fields ...*Field)
- func SimpleSource(filePath string) []source.Source
- func SprintFields() string
- func SprintTemplate(encoder string) string
- func Sync() error
- type Configurator
- type Field
- type Fields
- type Option
- func WithClassicSource(filePath, username, password, address string) Option
- func WithEtcdSource(prefix, username, password, address string) Option
- func WithLoader(l loader.Loader) Option
- func WithReader(r reader.Reader) Option
- func WithSimpleSource(filePath string) Option
- func WithSource(s ...source.Source) Option
- type Options
- type SubConfigurator
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ( // Default Config Manager Default = NewConfig() )
Functions ¶
func ClassicSource ¶
func EtcdSource ¶
func SimpleSource ¶
Types ¶
type Configurator ¶
type Configurator interface { // Load config sources Load(source ...source.Source) error // Force a source changeset sync Sync() error // Stop the config loader/watcher Close() error // Bytes get merged config data Bytes() []byte // SprintFields registered fields SprintFields() string // SprintTemplate through encoder SprintTemplate(encoder string) string // Watch, Mount, Getter value through field SubConfigurator }
Configurator is an interface abstraction for dynamic configuration
func NewClassic ¶
func NewClassic(filePath, username, password, address string) Configurator
NewClassic create a configurator with `file`, `env` and `etcd` source support. the priority is: `etcd` > `env` > `file`. `env` will use filename as prefix automatically. `etcd` key format: `/{fileName}/config`
func NewEtcd ¶
func NewEtcd(prefix, username, password, address string) Configurator
NewEtcd create a configurator with `etcd` source support. `etcd` key format: `/{prefix}/config`
func NewSimple ¶
func NewSimple(filePath string) Configurator
NewSimple create a configurator with `file` and `env` source support. the priority is: `env` > `file`. `env` will use filename as prefix automatically.
type Option ¶
type Option func(o *Options)
func WithClassicSource ¶
WithClassicSource create a option with `file`, `env` and `etcd` source support. the priority is: `etcd` > `env` > `file`. `env` will use filename as prefix automatically. `etcd` key format: `/{fileName}/config`
func WithEtcdSource ¶
WithEtcdSource create a option with `etcd` source support. `etcd` key format: `/{prefix}/config`
func WithLoader ¶
WithLoader sets the loader for manager config
func WithSimpleSource ¶
WithSimpleSource create a option with `file` and `env` source support. the priority is: `env` > `file`. `env` will use filename as prefix automatically.
func WithSource ¶
WithSource appends a source to list of sources
type SubConfigurator ¶
type SubConfigurator interface { // Watch field change Watch(field *Field) (Watcher, error) // Mount fields to configurator Mount(fields ...*Field) // Get value through field Get(field *Field) reader.Value // GetString through field GetBool(field *Field) bool // GetInt through field GetInt(field *Field) int // GetUint through field GetUint(field *Field) uint // GetString through field GetString(field *Field) string // GetFloat64 through field GetFloat64(field *Field) float64 // GetDuration through field GetDuration(field *Field) time.Duration // GetStringSlice through field GetStringSlice(field *Field) []string // GetStringMap through field GetStringMap(field *Field) map[string]string // GetBoxName path: box.name GetBoxName() string // GetTraceUid path: box.trace.uid GetTraceUid() string // GetTraceReqId path: box.trace.reqid GetTraceReqId() string // GetTraceBizId path: box.trace.bizid GetTraceBizId() string // GetTraceSpanId path: box.trace.spanid GetTraceSpanId() string }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package encoder handles source encoding formats
|
Package encoder handles source encoding formats |
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. |