viper

package module
v0.0.0-...-b326d97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2017 License: MIT Imports: 8 Imported by: 0

README

This code implements a thread-safe shim with a minimal API similar to Viper (github.com/spf13/viper)

Internally, 'gjson' is used, so similar path-notation that gjson supports can be used. (see https://github.com/tidwall/gjson )

It is released under the MIT license without support.

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

Constants

This section is empty.

Variables

View Source
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 GetBool

func GetBool(k string) bool

func GetInt

func GetInt(k string) int

func GetInt64

func GetInt64(k string) int64

func GetString

func GetString(k string) string

func GetStringSlice

func GetStringSlice(k string) []string

func ReadInConfig

func ReadInConfig() error

func ReadRemoteConfig

func ReadRemoteConfig() error

ReadRemoteConfig reads our remote config

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

func SetRemoteProvider(t string, addr string, keyPref string)

SetRemoteProvider t is type, currently unused, addr is consul address, keyPref is our configuration key

func StartWatcher

func StartWatcher(consulAddr string, consulKey string, delayInSeconds int) (chan error, error)

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

func UpdateConfig(cfg *string) error

UpdateConfig atomically swaps the current configuration, returns an error if the new config is not valid json

Types

This section is empty.

Directories

Path Synopsis
Package secconf implements secconf encoding as specified in the following format: base64(gpg(gzip(data)))
Package secconf implements secconf encoding as specified in the following format: base64(gpg(gzip(data)))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL