Documentation ¶
Index ¶
- Variables
- type BoolValuer
- type Event
- type EventKey
- type FloatValuer
- type IntValuer
- type Loader
- type Logger
- type Manager
- func (m *Manager) AllConfigs() map[string]interface{}
- func (m *Manager) Events() <-chan *Event
- func (m *Manager) Get(key string) (interface{}, error)
- func (m *Manager) GetBool(key string) (bool, error)
- func (m *Manager) GetBoolSlice(key string) ([]bool, error)
- func (m *Manager) GetDuration(key string) (time.Duration, error)
- func (m *Manager) GetDurationSlice(key string) ([]time.Duration, error)
- func (m *Manager) GetFloat32(key string) (float32, error)
- func (m *Manager) GetFloat64(key string) (float64, error)
- func (m *Manager) GetInt(key string) (int, error)
- func (m *Manager) GetInt16(key string) (int16, error)
- func (m *Manager) GetInt32(key string) (int32, error)
- func (m *Manager) GetInt64(key string) (int64, error)
- func (m *Manager) GetInt8(key string) (int8, error)
- func (m *Manager) GetIntSlice(key string) ([]int, error)
- func (m *Manager) GetSlice(key string) ([]interface{}, error)
- func (m *Manager) GetString(key string) (string, error)
- func (m *Manager) GetStringMap(key string) (map[string]interface{}, error)
- func (m *Manager) GetStringMapBool(key string) (map[string]bool, error)
- func (m *Manager) GetStringMapInt(key string) (map[string]int, error)
- func (m *Manager) GetStringMapInt64(key string) (map[string]int64, error)
- func (m *Manager) GetStringMapString(key string) (map[string]string, error)
- func (m *Manager) GetStringMapStringSlice(key string) (map[string][]string, error)
- func (m *Manager) GetStringSlice(key string) ([]string, error)
- func (m *Manager) GetTime(key string) (time.Time, error)
- func (m *Manager) GetUint(key string) (uint, error)
- func (m *Manager) GetUint16(key string) (uint16, error)
- func (m *Manager) GetUint32(key string) (uint32, error)
- func (m *Manager) GetUint64(key string) (uint64, error)
- func (m *Manager) GetUint8(key string) (uint8, error)
- func (m *Manager) ReadConfig() error
- func (m *Manager) StartWatch() error
- func (m *Manager) StopWatch() error
- func (m *Manager) Unmarshal(rawVal interface{}) error
- func (m *Manager) UnmarshalKey(key string, rawVal interface{}) error
- type MapValuer
- type NopLogger
- func (logger *NopLogger) Debug(args ...interface{})
- func (logger *NopLogger) Debugf(template string, args ...interface{})
- func (logger *NopLogger) Error(args ...interface{})
- func (logger *NopLogger) Errorf(template string, args ...interface{})
- func (logger *NopLogger) Info(args ...interface{})
- func (logger *NopLogger) Infof(template string, args ...interface{})
- func (logger *NopLogger) Warn(args ...interface{})
- func (logger *NopLogger) Warnf(template string, args ...interface{})
- type Option
- type Parser
- type SampleLogger
- func (logger *SampleLogger) Debug(args ...interface{})
- func (logger *SampleLogger) Debugf(template string, args ...interface{})
- func (logger *SampleLogger) Error(args ...interface{})
- func (logger *SampleLogger) Errorf(template string, args ...interface{})
- func (logger *SampleLogger) Info(args ...interface{})
- func (logger *SampleLogger) Infof(template string, args ...interface{})
- func (logger *SampleLogger) Warn(args ...interface{})
- func (logger *SampleLogger) Warnf(template string, args ...interface{})
- type SliceValuer
- type StringValuer
- type TimeValuer
- type Valuer
- type Watcher
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogger = NewSampleLogger(os.Stderr)
View Source
var DiscardLogger = &NopLogger{}
Functions ¶
This section is empty.
Types ¶
type BoolValuer ¶
type FloatValuer ¶
type IntValuer ¶
type IntValuer interface { // GetInt returns the value associated with the key as an int. GetInt(key string) (int, error) // GetInt8 returns the value associated with the key as an int8. GetInt8(key string) (int8, error) // GetInt16 returns the value associated with the key as an int16. GetInt16(key string) (int16, error) // GetInt32 returns the value associated with the key as an int32. GetInt32(key string) (int32, error) // GetInt64 returns the value associated with the key as an int64. GetInt64(key string) (int64, error) // GetUint returns the value associated with the key as an uint. GetUint(key string) (uint, error) // GetUint8 returns the value associated with the key as an uint8. GetUint8(key string) (uint8, error) // GetUint16 returns the value associated with the key as an uint16. GetUint16(key string) (uint16, error) // GetUint32 returns the value associated with the key as an uint32. GetUint32(key string) (uint32, error) // GetUint64 returns the value associated with the key as an uint64. GetUint64(key string) (uint64, error) }
type Loader ¶
type Loader interface { // ContentType get config content type ContentType() string // Load load config raw data from some where, like local file or remote server Load() error // RawData get raw data RawData() []byte }
Loader load data from some medium.
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(template string, args ...interface{}) Info(args ...interface{}) Infof(template string, args ...interface{}) Warn(args ...interface{}) Warnf(template string, args ...interface{}) Error(args ...interface{}) Errorf(template string, args ...interface{}) }
func NewSampleLogger ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager config manager, support mutil load
func NewManager ¶
func (*Manager) AllConfigs ¶
func (*Manager) GetDurationSlice ¶
func (*Manager) GetStringMap ¶
func (*Manager) GetStringMapBool ¶
func (*Manager) GetStringMapInt ¶
func (*Manager) GetStringMapInt64 ¶
func (*Manager) GetStringMapString ¶
func (*Manager) GetStringMapStringSlice ¶
func (*Manager) ReadConfig ¶
func (*Manager) StartWatch ¶
func (*Manager) UnmarshalKey ¶
type MapValuer ¶
type MapValuer interface { // GetStringMap returns the value associated with the key as a map of interfaces. GetStringMap(key string) (map[string]interface{}, error) // GetStringMapInt64 returns the value associated with the key as a map of int64. GetStringMapInt64(key string) (map[string]int64, error) // GetStringMapInt returns the value associated with the key as a map of int. GetStringMapInt(key string) (map[string]int, error) // GetStringMapBool returns the value associated with the key as a map of bool. GetStringMapBool(key string) (map[string]bool, error) // GetStringMapString returns the value associated with the key as a map of strings. GetStringMapString(key string) (map[string]string, error) // GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings. GetStringMapStringSlice(key string) (map[string][]string, error) }
type Option ¶
type Option func(mgr *Manager)
func WithLoader ¶
func WithParser ¶
func WithValuer ¶
func WithWatcher ¶
type Parser ¶
type Parser interface { // Parse unmarshal raw data into a config that type of `map[string]interface{}` // must ensure the sub value is type of `map[string]interface{}` Parse(rawData []byte) error // ConfigMap return config that type of `map[string]interface{}` ConfigMap() map[string]interface{} // Support returns true if the Parser supports this contentType, return false if the Parser not supports this contentType Support(contentType string) bool }
Parser encode raw data to map `map[string]interface{}`
type SampleLogger ¶
type SampleLogger struct { DebugLogger *log.Logger InfoLogger *log.Logger WarnLogger *log.Logger ErrorLogger *log.Logger }
func (*SampleLogger) Debug ¶
func (logger *SampleLogger) Debug(args ...interface{})
func (*SampleLogger) Debugf ¶
func (logger *SampleLogger) Debugf(template string, args ...interface{})
func (*SampleLogger) Error ¶
func (logger *SampleLogger) Error(args ...interface{})
func (*SampleLogger) Errorf ¶
func (logger *SampleLogger) Errorf(template string, args ...interface{})
func (*SampleLogger) Info ¶
func (logger *SampleLogger) Info(args ...interface{})
func (*SampleLogger) Infof ¶
func (logger *SampleLogger) Infof(template string, args ...interface{})
func (*SampleLogger) Warn ¶
func (logger *SampleLogger) Warn(args ...interface{})
func (*SampleLogger) Warnf ¶
func (logger *SampleLogger) Warnf(template string, args ...interface{})
type SliceValuer ¶
type SliceValuer interface { // GetSlice returns the value associated with the key as a slice of interface values. GetSlice(key string) ([]interface{}, error) // GetIntSlice returns the value associated with the key as a slice of int values. GetIntSlice(key string) ([]int, error) // GetBoolSlice returns the value associated with the key as a slice of bool values. GetBoolSlice(key string) ([]bool, error) // GetStringSlice returns the value associated with the key as a slice of strings. GetStringSlice(key string) ([]string, error) // GetDurationSlice returns the value associated with the key as a slice of duration. GetDurationSlice(key string) ([]time.Duration, error) }
type StringValuer ¶
type TimeValuer ¶
type Valuer ¶
type Valuer interface { // AddConfig add map[string]interface{} config AddConfig(configs ...map[string]interface{}) // AllConfigs merges all config and returns them as a map[string]interface{}. AllConfigs() map[string]interface{} // UnmarshalKey takes a single key and unmarshal it into a Struct. UnmarshalKey(key string, rawVal interface{}) error // Unmarshal unmarshal the config into a Struct. Unmarshal(rawVal interface{}) error // Get can retrieve any value given the key to use. Get(key string) (interface{}, error) FloatValuer IntValuer BoolValuer StringValuer TimeValuer SliceValuer MapValuer }
Valuer is Gets the value of a key, and Unmarshal value to a struct
Click to show internal directories.
Click to hide internal directories.