Documentation ¶
Overview ¶
Upgraded viper package
This is a thin thread-safe wrapper over the standard spf13/viper package. It supports simple remote polling with consul for config changes over YAML. We do not use much of the core viper code for doing this because none of it is thread- safe or supports 'dynamic reloading' the way I'd like to.
Index ¶
- Variables
- func CurrentConfig() *string
- func GetBool(k string) bool
- func GetInt(k string) int
- func GetInt64(k string) int64
- func GetString(k string) string
- func GetStringSlice(k string) []string
- func ReadInConfig() error
- func ReadRemoteConfig() error
- func SetConfigFile(f string)
- func SetConfigType(t string)
- func SetRemoteProvider(t string, addr string, keyPref string)
- func StartWatcher(consulAddr string, consulKey string, delayInSeconds int) (chan error, error)
- func StartWatcherListener(watcherCh chan error)
- func UpdateConfig(cfg *string) error
Constants ¶
This section is empty.
Variables ¶
var ErrNilReadFromConsul = errors.New("nil was read")
ErrNilReadFromConsul is for when determing when consul has read an unset key
Functions ¶
func CurrentConfig ¶
func CurrentConfig() *string
CurrentConfig atomically returns the current configuration
func GetStringSlice ¶
func ReadInConfig ¶
func ReadInConfig() error
func SetConfigFile ¶
func SetConfigFile(f string)
func SetConfigType ¶
func SetConfigType(t string)
SetConfigType only accepts JSON for the time being, this is mostly a placeholder method
func SetRemoteProvider ¶
SetRemoteProvider t is type, currently unused, addr is consul address, keyPref is our configuration key
func StartWatcher ¶
StartWatcher encapsulates a basic polling watcher on a given consul key. Calling this routine spawns a goroutine which polls a given consul address for a specific consul key. It tracks internal state based on the last value read and only sends nil to the channel when the config
It returns an error channel, or nil and an error if it is unable to create a new consul client.
func StartWatcherListener ¶
func StartWatcherListener(watcherCh chan error)
func UpdateConfig ¶
UpdateConfig atomically swaps the current configuration, returns an error if the new config is not valid json
Types ¶
This section is empty.