Documentation ¶
Index ¶
- Variables
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetInt(key string) int
- func GetMapStringBool(key string) map[string]bool
- func GetMapStringInt(key string) map[string]int
- func GetMapStringInterface(key string) map[string]interface{}
- func GetMapStringString(key string) map[string]string
- func GetString(key string) string
- func Init(f godb.JSONFetcher, configFetchPath string, baseConfig []byte, ...) error
- func StopUpdates()
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoConfig = errors.New("no config available. did you call init?") ErrNotValidJSON = errors.New("base config must be valid json") )
Functions ¶
func Get ¶
func Get(key string) interface{}
Get returns the value of the given configuration element at the specified key as the JSON Type as it exists at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetBool ¶
GetBool returns the value of the given configuration element at the specified key as an bool, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetInt ¶
GetInt returns the value of the given configuration element at the specified key as an int, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetMapStringBool ¶
GetMapStringBool returns the value of the given configuration element at the specified key as map[string]bool, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetMapStringInt ¶
GetMapStringInt returns the value of the given configuration element at the specified key as map[string]int, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetMapStringInterface ¶
GetMapStringInterface returns the value of the given configuration element at the specified key as map[string]interface{}, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetMapStringString ¶
GetMapStringString returns the value of the given configuration element at the specified key as map[string]string, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func GetString ¶
GetString returns the value of the given configuration element at the specified key as a string, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)
func Init ¶ added in v1.0.45
func Init(f godb.JSONFetcher, configFetchPath string, baseConfig []byte, envMap map[string]string, updateFrequency time.Duration) error
fetcher is used to retrieve override configs and a response to a query is expected to return JSON. If fetcher is nil, that functionality is disabled, and only baseConfig and envMap will be used.
BaseConfig is the default configuration. Configuration that is expected to be overridden by environment variables should be at the root level and be simple values. Secrets should (probably) come from the environment and not be comitted with code.
EnvMap maps a BaseConfig key onto the Environmental Key that overrides it. Environmental configurations must be strings in the BaseConfig, though you can use the Get* to convert to a desired type. Environmental configs are those things which are:
- Vital to the functionality of the service; or
- Secret in nature
ex: "host": "HOST" "port": "PORT" "defaultTimeout": "TIMEOUT" "env": "ENV" "dbConnectString": "DB_CONNECT_STRING"
func StopUpdates ¶ added in v1.0.45
func StopUpdates()
StopUpdates sends a stop signal if there is a currently running updater.
Types ¶
This section is empty.