Documentation ¶
Index ¶
- Constants
- func Describe(names ...string)
- func Print(printfn func(string, ...interface{}))
- func SetConfig(cfg map[string]string) error
- func SetConfigFromFile(path string) error
- func SetLogger(logger Logger)
- type Data
- type Event
- type GetConfigFn
- type Logger
- type Module
- type NotifyFn
- type Option
- type Source
Constants ¶
const ( // UpdateEvent corresponds to a normal configuration udpate. UpdateEvent = "update" // RevertEvent corresponds to a configuration rollback in case of errors. RevertEvent = "rollback" )
const (
// MainModule is the default parent for all configuration.
MainModule = "main"
)
Variables ¶
This section is empty.
Functions ¶
func Describe ¶
func Describe(names ...string)
Describe provides help about configuration of the given modules.
func Print ¶
func Print(printfn func(string, ...interface{}))
Print prints the current configuration, using the given function or fmt.Printf.
func SetConfigFromFile ¶
SetConfigFromFile updates the configuration from the given file.
Types ¶
type Data ¶
type Data map[string]interface{}
Data is our internal representation of configuration data.
func DataFromFile ¶
DataFromFile unmarshals the content of the given file into configuration data.
func DataFromObject ¶
DataFromObject remarshals the given object into configuration data.
func DataFromStringMap ¶
DataFromStringMap remarshals the given map into configuration data.
type Event ¶
type Event string
Event describes what triggered an invocation of a configuration notification callback.
type GetConfigFn ¶
type GetConfigFn func() interface{}
GetConfigFn is used to query a module for its default configuration.
type Logger ¶
type Logger struct { DebugEnabled func() bool Debug func(string, ...interface{}) Info func(string, ...interface{}) Warning func(string, ...interface{}) Error func(string, ...interface{}) Fatal func(string, ...interface{}) Panic func(string, ...interface{}) Block func(func(string, ...interface{}), string, string, ...interface{}) }
Logger is our set of logging functions.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is a logical unit of configuration, declared using Declare().
func GetModule ¶
GetModule looks up the module for the given path, implicitly creating it if necessary.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is the generic interface for any option applicable to a Module or Config.
func WithNotify ¶
WithNotify specifies a notification function to be called after configuration updates.
func WithoutDataValidation ¶
func WithoutDataValidation() Option
WithoutDataValidation specifies that data passed to this module should not be validated.
type Source ¶
type Source string
Source describes where configuration is originated from.
const ( // ConfigFile is a YAML/JSON file configuration source. ConfigFile Source = "configuration file" // ConfigExternal is an external configuration source, for instance a node agent. ConfigExternal Source = "external configuration" // ConfigBackup is a backup of the previous configuration. ConfigBackup Source = "backed up configuration" )