config

package
v1.0.47 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func GetBool(key string) bool

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

func GetInt(key string) int

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

func GetMapStringBool(key string) map[string]bool

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

func GetMapStringInt(key string) map[string]int

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

func GetMapStringInterface(key string) map[string]interface{}

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

func GetMapStringString(key string) map[string]string

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

func GetString(key string) string

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.

Jump to

Keyboard shortcuts

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