Documentation ¶
Overview ¶
Package config uses the exact same precedence order as Viper, where each item takes precedence over the item below it:
- explicit call to Set (case insensitive)
- flag (case insensitive)
- env (case sensitive - see notes below)
- config (case insensitive)
- key/value store (case insensitive)
- default (case insensitive)
Environment variable resolution is performed based on the following rules:
- If the key contains only uppercase characters, numbers and underscores, the environment variable is looked up in its entirety, e.g. SOME_VARIABLE -> SOME_VARIABLE
- In all other cases, the environment variable is transformed before being looked up as following: 1. camelCase is converted to snake_case, e.g. someVariable -> some_variable 2. dots (.) are replaced with underscores (_), e.g. some.variable -> some_variable 3. the resulting string is uppercased and prefixed with RSERVER_, e.g. some_variable -> RSERVER_SOME_VARIABLE
Index ¶
- Constants
- func ConfigKeyToEnv(s string) string
- func GetBool(key string, defaultValue bool) (value bool)
- func GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
- func GetFloat64(key string, defaultValue float64) (value float64)
- func GetInstanceID() string
- func GetInt(key string, defaultValue int) (value int)
- func GetInt64(key string, defaultValue int64) (value int64)
- func GetKubeNamespace() string
- func GetNamespaceIdentifier() string
- func GetReleaseName() string
- func GetString(key, defaultValue string) (value string)
- func GetWorkspaceToken() string
- func IsSet(key string) bool
- func MustGetInt(key string) (value int)
- func MustGetString(key string) (value string)
- func RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, keys ...string)
- func RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, ...)
- func RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)
- func RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, ...)
- func RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, ...)
- func RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)
- func RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, keys ...string)
- func Reset()
- func Set(key string, value interface{})
- type Config
- func (c *Config) GetBool(key string, defaultValue bool) (value bool)
- func (c *Config) GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
- func (c *Config) GetFloat64(key string, defaultValue float64) (value float64)
- func (c *Config) GetInt(key string, defaultValue int) (value int)
- func (c *Config) GetInt64(key string, defaultValue int64) (value int64)
- func (c *Config) GetString(key, defaultValue string) (value string)
- func (c *Config) GetStringSlice(key string, defaultValue []string) (value []string)
- func (c *Config) IsSet(key string) bool
- func (c *Config) MustGetInt(key string) (value int)
- func (c *Config) MustGetString(key string) (value string)
- func (c *Config) RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, keys ...string)
- func (c *Config) RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, ...)
- func (c *Config) RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)
- func (c *Config) RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, ...)
- func (c *Config) RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, ...)
- func (c *Config) RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)
- func (c *Config) RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, keys ...string)
- func (c *Config) Set(key string, value interface{})
Constants ¶
const ( EmbeddedMode = "embedded" MasterMode = "master" MasterSlaveMode = "master_and_slave" SlaveMode = "slave" OffMode = "off" PooledWHSlaveMode = "embedded_master" )
Rudder server supported config constants
Variables ¶
This section is empty.
Functions ¶
func ConfigKeyToEnv ¶ added in v1.2.0
ConfigKeyToEnv gets the env variable name from a given config key
func GetDuration ¶
func GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
GetDuration gets duration value from config
func GetFloat64 ¶
GetFloat64 gets float64 value from config
func GetInstanceID ¶ added in v0.1.10
func GetInstanceID() string
func GetKubeNamespace ¶ added in v0.1.10
func GetKubeNamespace() string
GetKubeNamespace returns value stored in KUBE_NAMESPACE env var
func GetNamespaceIdentifier ¶ added in v0.1.10
func GetNamespaceIdentifier() string
GetNamespaceIdentifier
func GetReleaseName ¶ added in v0.1.10
func GetReleaseName() string
func GetWorkspaceToken ¶
func GetWorkspaceToken() string
GetWorkspaceToken returns the workspace token provided in the environment variables Env variable CONFIG_BACKEND_TOKEN is deprecating soon WORKSPACE_TOKEN is newly introduced. This will override CONFIG_BACKEND_TOKEN
func MustGetInt ¶ added in v1.2.0
MustGetInt gets int value from config or panics if the config doesn't exist
func MustGetString ¶ added in v1.2.0
MustGetString gets string value from config or panics if the config doesn't exist
func RegisterBoolConfigVariable ¶ added in v0.1.10
RegisterBoolConfigVariable registers bool config variable
func RegisterDurationConfigVariable ¶ added in v0.1.10
func RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, keys ...string)
RegisterDurationConfigVariable registers duration config variable
func RegisterFloat64ConfigVariable ¶ added in v0.1.10
func RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)
RegisterFloat64ConfigVariable registers float64 config variable
func RegisterInt64ConfigVariable ¶ added in v0.1.10
func RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, keys ...string)
RegisterInt64ConfigVariable registers int64 config variable
func RegisterIntConfigVariable ¶ added in v0.1.10
func RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, keys ...string)
RegisterIntConfigVariable registers int config variable
func RegisterStringConfigVariable ¶ added in v0.1.10
func RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)
RegisterStringConfigVariable registers string config variable
func RegisterStringSliceConfigVariable ¶ added in v0.1.10
func RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, keys ...string)
RegisterStringSliceConfigVariable registers string slice config variable
Types ¶
type Config ¶ added in v1.2.0
type Config struct {
// contains filtered or unexported fields
}
Config is the entry point for accessing configuration
var Default *Config
default, singleton config instance
func (*Config) GetDuration ¶ added in v1.2.0
func (c *Config) GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
GetDuration gets duration value from config
func (*Config) GetFloat64 ¶ added in v1.2.0
GetFloat64 gets float64 value from config
func (*Config) GetStringSlice ¶ added in v1.2.0
GetStringSlice gets string slice value from config
func (*Config) MustGetInt ¶ added in v1.2.0
MustGetInt gets int value from config or panics if the config doesn't exist
func (*Config) MustGetString ¶ added in v1.2.0
MustGetString gets string value from config or panics if the config doesn't exist
func (*Config) RegisterBoolConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, keys ...string)
RegisterBoolConfigVariable registers bool config variable
func (*Config) RegisterDurationConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, keys ...string)
RegisterDurationConfigVariable registers duration config variable
func (*Config) RegisterFloat64ConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)
RegisterFloat64ConfigVariable registers float64 config variable
func (*Config) RegisterInt64ConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, keys ...string)
RegisterInt64ConfigVariable registers int64 config variable
func (*Config) RegisterIntConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, keys ...string)
RegisterIntConfigVariable registers int config variable
func (*Config) RegisterStringConfigVariable ¶ added in v1.2.0
func (c *Config) RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)
RegisterStringConfigVariable registers string config variable
Directories ¶
Path | Synopsis |
---|---|
Package backendconfig is a generated GoMock package.
|
Package backendconfig is a generated GoMock package. |
internal/cache
Package cache is a generated GoMock package.
|
Package cache is a generated GoMock package. |