Documentation
¶
Index ¶
- Constants
- type Loader
- type Option
- func ErrorHandler(f func(err error)) Option
- func OptDebounceInterval(v time.Duration) Option
- func OptDebounceMaxDelay(v time.Duration) Option
- func OptKeepLatestOnFailure() Option
- func OptStrictParsing() Option
- func ReloadHandler(f func(interface{})) Option
- func ValidationHandler(f func(interface{}) (interface{}, error)) Option
Constants ¶
const ( // DefaultDebounceInterval defines the default debounce interval of 100ms DefaultDebounceInterval = 1000 * time.Millisecond // DefaultDebounceMaxDelay defines the default debounce max delay of 3s DefaultDebounceMaxDelay = 3 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads and watches config
func (*Loader) Get ¶
func (c *Loader) Get() interface{}
Get returns the current version of the configuraiton stored in the loader
func (*Loader) GetDefaults ¶
func (c *Loader) GetDefaults() interface{}
GetDefaults returns a copy of the default config
type Option ¶
type Option func(*Loader)
Option is the base tupe for configuration options
func ErrorHandler ¶
ErrorHandler attaches a function to be called when an error occurs during a background opration, e.g. while reloading the configuration file
func OptDebounceInterval ¶
OptDebounceInterval set the debounce interval for rapid changes to the configuration file. Default interval is 100ms
func OptDebounceMaxDelay ¶
OptDebounceMaxDelay set the maximum delay that can be caused by the debouncing process, in case the target configuration file is constantly cahning. The default value is 3s.
func OptKeepLatestOnFailure ¶
func OptKeepLatestOnFailure() Option
OptKeepLatestOnFailure activate an option that will keep the latest valid configuration if the new configuration fails to load. The default behavior is to revert to the default settings. This option is not recommended for application running in a cluster orchestration environment.
func OptStrictParsing ¶
func OptStrictParsing() Option
OptStrictParsing activate the strict option for the underlying parsing of the configuration file, i.e. fields that are unknown generate an error rather than being silently ignored
func ReloadHandler ¶
func ReloadHandler(f func(interface{})) Option
ReloadHandler attaches a function to be called when the configuration is reloaded
func ValidationHandler ¶
ValidationHandler attaches a function to be called when a new configuration is loaded, but before it propagates through the system. The handler can modify or enhance the config object, and can abort the update by returning an error.
Directories
¶
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
debounce
Package debounce implements debounce logic for external events.
|
Package debounce implements debounce logic for external events. |
|
watch
Package watch provides watch events for a filesystem location.
|
Package watch provides watch events for a filesystem location. |