Documentation ¶
Index ¶
- type C
- func (c *C) CatchHUP(ctx context.Context)
- func (c *C) Get(k string) interface{}
- func (c *C) GetBool(k string, d bool) bool
- func (c *C) GetDuration(k string, d time.Duration) time.Duration
- func (c *C) GetInt(k string, d int) int
- func (c *C) GetMap(k string, d map[interface{}]interface{}) map[interface{}]interface{}
- func (c *C) GetString(k, d string) string
- func (c *C) GetStringSlice(k string, d []string) []string
- func (c *C) GetUint32(k string, d uint32) uint32
- func (c *C) HasChanged(k string) bool
- func (c *C) InitialLoad() bool
- func (c *C) IsSet(k string) bool
- func (c *C) Load(path string) error
- func (c *C) LoadString(raw string) error
- func (c *C) RegisterReloadCallback(f func(*C))
- func (c *C) ReloadConfig()
- func (c *C) ReloadConfigString(raw string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type C ¶
type C struct { Settings map[interface{}]interface{} // contains filtered or unexported fields }
func (*C) CatchHUP ¶
CatchHUP will listen for the HUP signal in a go routine and reload all configs found in the original path provided to Load. The old settings are shallow copied for change detection after the reload.
func (*C) GetDuration ¶
GetDuration will get the duration for k or return the default d if not found or invalid
func (*C) GetString ¶
GetString will get the string for k or return the default d if not found or invalid
func (*C) GetStringSlice ¶
GetStringSlice will get the slice of strings for k or return the default d if not found or invalid
func (*C) GetUint32 ¶ added in v1.8.0
GetUint32 will get the uint32 for k or return the default d if not found or invalid
func (*C) HasChanged ¶
HasChanged checks if the underlying structure of the provided key has changed after a config reload. The value of k in both the old and new settings will be serialized, the result of the string comparison is returned. If k is an empty string the entire config is tested. It's important to note that this is very rudimentary and susceptible to configuration ordering issues indicating there is change when there actually wasn't any.
func (*C) InitialLoad ¶ added in v1.6.0
InitialLoad returns true if this is the first load of the config, and ReloadConfig has not been called yet.
func (*C) LoadString ¶
func (*C) RegisterReloadCallback ¶
RegisterReloadCallback stores a function to be called when a config reload is triggered. The functions registered here should decide if they need to make a change to the current process before making the change. HasChanged can be used to help decide if a change is necessary. These functions should return quickly or spawn their own go routine if they will take a while
func (*C) ReloadConfig ¶
func (c *C) ReloadConfig()