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 ${PREFIX}_ (default RSERVER_), e.g. some_variable -> RSERVER_SOME_VARIABLE
Order of keys:
When registering a variable with multiple keys, the order of the keys is important as it determines the hierarchical order of the keys. The first key is the most important one, and the last key is the least important one. Example: config.RegisterDurationConfigVariable(90, &cmdTimeout, true, time.Second, "JobsDB.Router.CommandRequestTimeout", "JobsDB.CommandRequestTimeout", ) In the above example "JobsDB.Router.CommandRequestTimeout" is checked first. If it doesn't exist then JobsDB.CommandRequestTimeout is checked. WARNING: for this reason, registering with the same keys but in a different order is going to return two different variables.
Index ¶
- Constants
- func ConfigKeyToEnv(envPrefix, s string) string
- func GetBool(key string, defaultValue bool) (value bool)
- func GetBoolVar(defaultValue bool, orderedKeys ...string) bool
- func GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
- func GetDurationVar(defaultValueInTimescaleUnits int64, timeScale time.Duration, ...) time.Duration
- func GetFloat64(key string, defaultValue float64) (value float64)
- func GetFloat64Var(defaultValue float64, orderedKeys ...string) float64
- func GetInt(key string, defaultValue int) (value int)
- func GetInt64(key string, defaultValue int64) (value int64)
- func GetInt64Var(defaultValue, valueScale int64, orderedKeys ...string) int64
- func GetIntVar(defaultValue, valueScale int, orderedKeys ...string) int
- func GetKubeNamespace() string
- func GetNamespaceIdentifier() string
- func GetReleaseName() string
- func GetString(key, defaultValue string) (value string)
- func GetStringMap(key string, defaultValue map[string]interface{}) (value map[string]interface{})
- func GetStringMapVar(defaultValue map[string]interface{}, orderedKeys ...string) map[string]interface{}
- func GetStringSlice(key string, defaultValue []string) (value []string)
- func GetStringSliceVar(defaultValue []string, orderedKeys ...string) []string
- func GetStringVar(defaultValue string, orderedKeys ...string) 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, orderedKeys ...string)deprecated
- func RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, ...)deprecated
- func RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, ...)deprecated
- func RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, ...)deprecated
- func RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, ...)deprecated
- func RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, orderedKeys ...string)deprecated
- func RegisterStringMapConfigVariable(defaultValue map[string]interface{}, ptr *map[string]interface{}, ...)deprecated
- func RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, ...)deprecated
- func Reset()
- func Set(key string, value interface{})
- type Config
- func (c *Config) ConfigFileUsed() (string, error)
- func (c *Config) DotEnvLoaded() error
- func (c *Config) GetBool(key string, defaultValue bool) (value bool)
- func (c *Config) GetBoolVar(defaultValue bool, orderedKeys ...string) bool
- func (c *Config) GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
- func (c *Config) GetDurationVar(defaultValueInTimescaleUnits int64, timeScale time.Duration, ...) time.Duration
- func (c *Config) GetFloat64(key string, defaultValue float64) (value float64)
- func (c *Config) GetFloat64Var(defaultValue float64, orderedKeys ...string) float64
- func (c *Config) GetInt(key string, defaultValue int) (value int)
- func (c *Config) GetInt64(key string, defaultValue int64) (value int64)
- func (c *Config) GetInt64Var(defaultValue, valueScale int64, orderedKeys ...string) int64
- func (c *Config) GetIntVar(defaultValue, valueScale int, orderedKeys ...string) int
- func (c *Config) GetReloadableBoolVar(defaultValue bool, orderedKeys ...string) *Reloadable[bool]
- func (c *Config) GetReloadableDurationVar(defaultValueInTimescaleUnits int64, timeScale time.Duration, ...) *Reloadable[time.Duration]
- func (c *Config) GetReloadableFloat64Var(defaultValue float64, orderedKeys ...string) *Reloadable[float64]
- func (c *Config) GetReloadableInt64Var(defaultValue, valueScale int64, orderedKeys ...string) *Reloadable[int64]
- func (c *Config) GetReloadableIntVar(defaultValue, valueScale int, orderedKeys ...string) *Reloadable[int]
- func (c *Config) GetReloadableStringMapVar(defaultValue map[string]interface{}, orderedKeys ...string) *Reloadable[map[string]interface{}]
- func (c *Config) GetReloadableStringSliceVar(defaultValue []string, orderedKeys ...string) *Reloadable[[]string]
- func (c *Config) GetReloadableStringVar(defaultValue string, orderedKeys ...string) *Reloadable[string]
- func (c *Config) GetString(key, defaultValue string) (value string)
- func (c *Config) GetStringMap(key string, defaultValue map[string]interface{}) (value map[string]interface{})
- func (c *Config) GetStringMapVar(defaultValue map[string]interface{}, orderedKeys ...string) map[string]interface{}
- func (c *Config) GetStringSlice(key string, defaultValue []string) (value []string)
- func (c *Config) GetStringSliceVar(defaultValue []string, orderedKeys ...string) []string
- func (c *Config) GetStringVar(defaultValue string, orderedKeys ...string) 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, orderedKeys ...string)deprecated
- func (c *Config) RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, ...)deprecated
- func (c *Config) RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, ...)deprecated
- func (c *Config) RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, ...)deprecated
- func (c *Config) RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, ...)deprecated
- func (c *Config) RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, orderedKeys ...string)deprecated
- func (c *Config) RegisterStringMapConfigVariable(defaultValue map[string]interface{}, ptr *map[string]interface{}, ...)deprecated
- func (c *Config) RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, ...)deprecated
- func (c *Config) Set(key string, value interface{})
- type Opt
- type Reloadable
- func GetReloadableBoolVar(defaultValue bool, orderedKeys ...string) *Reloadable[bool]
- func GetReloadableDurationVar(defaultValueInTimescaleUnits int64, timeScale time.Duration, ...) *Reloadable[time.Duration]
- func GetReloadableFloat64Var(defaultValue float64, orderedKeys ...string) *Reloadable[float64]
- func GetReloadableInt64Var(defaultValue, valueScale int64, orderedKeys ...string) *Reloadable[int64]
- func GetReloadableIntVar(defaultValue, valueScale int, orderedKeys ...string) *Reloadable[int]
- func GetReloadableStringMapVar(defaultValue map[string]interface{}, orderedKeys ...string) *Reloadable[map[string]interface{}]
- func GetReloadableStringSliceVar(defaultValue []string, orderedKeys ...string) *Reloadable[[]string]
- func GetReloadableStringVar(defaultValue string, orderedKeys ...string) *Reloadable[string]
- type ValueLoader
Constants ¶
const ( EmbeddedMode = "embedded" MasterMode = "master" MasterSlaveMode = "master_and_slave" SlaveMode = "slave" OffMode = "off" EmbeddedMasterMode = "embedded_master" )
Rudder server supported config constants
const DefaultEnvPrefix = "RSERVER"
Variables ¶
This section is empty.
Functions ¶
func ConfigKeyToEnv ¶
ConfigKeyToEnv gets the env variable name from a given config key
func GetBoolVar ¶ added in v0.15.9
GetBoolVar registers a not hot-reloadable bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetDuration ¶
func GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
GetDuration gets duration value from config
func GetDurationVar ¶ added in v0.15.9
func GetDurationVar( defaultValueInTimescaleUnits int64, timeScale time.Duration, orderedKeys ...string, ) time.Duration
GetDurationVar registers a not hot-reloadable duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetFloat64 ¶
GetFloat64 gets float64 value from config
func GetFloat64Var ¶ added in v0.15.9
GetFloat64Var registers a not hot-reloadable float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetInt64Var ¶ added in v0.15.9
GetInt64Var registers a not hot-reloadable int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetIntVar ¶ added in v0.15.9
GetIntVar registers a not hot-reloadable int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetKubeNamespace ¶
func GetKubeNamespace() string
GetKubeNamespace returns value stored in KUBE_NAMESPACE env var
func GetNamespaceIdentifier ¶
func GetNamespaceIdentifier() string
GetNamespaceIdentifier returns value stored in KUBE_NAMESPACE env var or "none" if empty
func GetReleaseName ¶
func GetReleaseName() string
func GetStringMap ¶
GetStringMap gets string map value from config
func GetStringMapVar ¶ added in v0.15.9
func GetStringMapVar(defaultValue map[string]interface{}, orderedKeys ...string) map[string]interface{}
GetStringMapVar registers a not hot-reloadable string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetStringSlice ¶
GetStringSlice gets string slice value from config
func GetStringSliceVar ¶ added in v0.15.9
GetStringSliceVar registers a not hot-reloadable string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetStringVar ¶ added in v0.15.9
GetStringVar registers a not hot-reloadable string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
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 ¶
MustGetInt gets int value from config or panics if the config doesn't exist
func MustGetString ¶
MustGetString gets string value from config or panics if the config doesn't exist
func RegisterBoolConfigVariable
deprecated
func RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, orderedKeys ...string)
RegisterBoolConfigVariable registers bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetBoolVar or GetReloadableBoolVar instead
func RegisterDurationConfigVariable
deprecated
func RegisterDurationConfigVariable( defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, orderedKeys ...string, )
RegisterDurationConfigVariable registers duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetDurationVar or GetReloadableDurationVar instead
func RegisterFloat64ConfigVariable
deprecated
func RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, orderedKeys ...string)
RegisterFloat64ConfigVariable registers float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetFloat64Var or GetReloadableFloat64Var instead
func RegisterInt64ConfigVariable
deprecated
func RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, orderedKeys ...string)
RegisterInt64ConfigVariable registers int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetInt64Var or GetReloadableInt64Var instead
func RegisterIntConfigVariable
deprecated
func RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, orderedKeys ...string)
RegisterIntConfigVariable registers int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetIntVar or GetReloadableIntVar instead
func RegisterStringConfigVariable
deprecated
func RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, orderedKeys ...string)
RegisterStringConfigVariable registers string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringVar or GetReloadableStringVar instead
func RegisterStringMapConfigVariable
deprecated
func RegisterStringMapConfigVariable( defaultValue map[string]interface{}, ptr *map[string]interface{}, isHotReloadable bool, orderedKeys ...string, )
RegisterStringMapConfigVariable registers string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringMapVar or GetReloadableStringMapVar instead
func RegisterStringSliceConfigVariable
deprecated
func RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, orderedKeys ...string)
RegisterStringSliceConfigVariable registers string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringSliceVar or GetReloadableStringSliceVar instead
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the entry point for accessing configuration
var Default *Config
Default is the singleton config instance
func (*Config) ConfigFileUsed ¶ added in v0.25.0
ConfigFileUsed returns the file used to load the config. If we failed to load the config file, it also returns an error.
func (*Config) DotEnvLoaded ¶ added in v0.25.0
DotEnvLoaded returns an error if there was an error loading the .env file. It returns nil otherwise.
func (*Config) GetBoolVar ¶ added in v0.15.9
GetBoolVar registers a not hot-reloadable bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetDuration ¶
func (c *Config) GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)
GetDuration gets duration value from config
func (*Config) GetDurationVar ¶ added in v0.15.9
func (c *Config) GetDurationVar( defaultValueInTimescaleUnits int64, timeScale time.Duration, orderedKeys ...string, ) time.Duration
GetDurationVar registers a not hot-reloadable duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetFloat64 ¶
GetFloat64 gets float64 value from config
func (*Config) GetFloat64Var ¶ added in v0.15.9
GetFloat64Var registers a not hot-reloadable float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetInt64Var ¶ added in v0.15.9
GetInt64Var registers a not hot-reloadable int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetIntVar ¶ added in v0.15.9
GetIntVar registers a not hot-reloadable int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableBoolVar ¶ added in v0.15.9
func (c *Config) GetReloadableBoolVar(defaultValue bool, orderedKeys ...string) *Reloadable[bool]
GetReloadableBoolVar registers a hot-reloadable bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableDurationVar ¶ added in v0.15.9
func (c *Config) GetReloadableDurationVar( defaultValueInTimescaleUnits int64, timeScale time.Duration, orderedKeys ...string, ) *Reloadable[time.Duration]
GetReloadableDurationVar registers a hot-reloadable duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableFloat64Var ¶ added in v0.15.9
func (c *Config) GetReloadableFloat64Var(defaultValue float64, orderedKeys ...string) *Reloadable[float64]
GetReloadableFloat64Var registers a hot-reloadable float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableInt64Var ¶ added in v0.15.9
func (c *Config) GetReloadableInt64Var(defaultValue, valueScale int64, orderedKeys ...string) *Reloadable[int64]
GetReloadableInt64Var registers a not hot-reloadable int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableIntVar ¶ added in v0.15.9
func (c *Config) GetReloadableIntVar(defaultValue, valueScale int, orderedKeys ...string) *Reloadable[int]
GetReloadableIntVar registers a hot-reloadable int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableStringMapVar ¶ added in v0.15.9
func (c *Config) GetReloadableStringMapVar( defaultValue map[string]interface{}, orderedKeys ...string, ) *Reloadable[map[string]interface{}]
GetReloadableStringMapVar registers a hot-reloadable string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableStringSliceVar ¶ added in v0.15.9
func (c *Config) GetReloadableStringSliceVar(defaultValue []string, orderedKeys ...string) *Reloadable[[]string]
GetReloadableStringSliceVar registers a hot-reloadable string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetReloadableStringVar ¶ added in v0.15.9
func (c *Config) GetReloadableStringVar(defaultValue string, orderedKeys ...string) *Reloadable[string]
GetReloadableStringVar registers a hot-reloadable string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetStringMap ¶
func (c *Config) GetStringMap(key string, defaultValue map[string]interface{}) (value map[string]interface{})
GetStringMap gets string map value from config
func (*Config) GetStringMapVar ¶ added in v0.15.9
func (c *Config) GetStringMapVar( defaultValue map[string]interface{}, orderedKeys ...string, ) map[string]interface{}
GetStringMapVar registers a not hot-reloadable string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetStringSlice ¶
GetStringSlice gets string slice value from config
func (*Config) GetStringSliceVar ¶ added in v0.15.9
GetStringSliceVar registers a not hot-reloadable string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) GetStringVar ¶ added in v0.15.9
GetStringVar registers a not hot-reloadable string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Config) MustGetInt ¶
MustGetInt gets int value from config or panics if the config doesn't exist
func (*Config) MustGetString ¶
MustGetString gets string value from config or panics if the config doesn't exist
func (*Config) RegisterBoolConfigVariable
deprecated
func (c *Config) RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, orderedKeys ...string)
RegisterBoolConfigVariable registers bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetBoolVar or GetReloadableBoolVar instead
func (*Config) RegisterDurationConfigVariable
deprecated
func (c *Config) RegisterDurationConfigVariable( defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, orderedKeys ...string, )
RegisterDurationConfigVariable registers duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetDurationVar or GetReloadableDurationVar instead
func (*Config) RegisterFloat64ConfigVariable
deprecated
func (c *Config) RegisterFloat64ConfigVariable( defaultValue float64, ptr *float64, isHotReloadable bool, orderedKeys ...string, )
RegisterFloat64ConfigVariable registers float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetFloat64Var or GetReloadableFloat64Var instead
func (*Config) RegisterInt64ConfigVariable
deprecated
func (c *Config) RegisterInt64ConfigVariable( defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, orderedKeys ...string, )
RegisterInt64ConfigVariable registers int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetInt64Var or GetReloadableInt64Var instead
func (*Config) RegisterIntConfigVariable
deprecated
func (c *Config) RegisterIntConfigVariable( defaultValue int, ptr *int, isHotReloadable bool, valueScale int, orderedKeys ...string, )
RegisterIntConfigVariable registers int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetIntVar or GetReloadableIntVar instead
func (*Config) RegisterStringConfigVariable
deprecated
func (c *Config) RegisterStringConfigVariable( defaultValue string, ptr *string, isHotReloadable bool, orderedKeys ...string, )
RegisterStringConfigVariable registers string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringVar or GetReloadableStringVar instead
func (*Config) RegisterStringMapConfigVariable
deprecated
func (c *Config) RegisterStringMapConfigVariable( defaultValue map[string]interface{}, ptr *map[string]interface{}, isHotReloadable bool, orderedKeys ...string, )
RegisterStringMapConfigVariable registers string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringMapVar or GetReloadableStringMapVar instead
func (*Config) RegisterStringSliceConfigVariable
deprecated
func (c *Config) RegisterStringSliceConfigVariable( defaultValue []string, ptr *[]string, isHotReloadable bool, orderedKeys ...string, )
RegisterStringSliceConfigVariable registers string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
Deprecated: use GetStringSliceVar or GetReloadableStringSliceVar instead
type Opt ¶
type Opt func(*Config)
func WithEnvPrefix ¶
WithEnvPrefix sets the environment variable prefix (default: RSERVER)
type Reloadable ¶ added in v0.15.9
type Reloadable[T configTypes] struct {
// contains filtered or unexported fields
}
Reloadable is used as a wrapper for hot-reloadable config variables
func GetReloadableBoolVar ¶ added in v0.15.9
func GetReloadableBoolVar(defaultValue bool, orderedKeys ...string) *Reloadable[bool]
GetReloadableBoolVar registers a hot-reloadable bool config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableDurationVar ¶ added in v0.15.9
func GetReloadableDurationVar(defaultValueInTimescaleUnits int64, timeScale time.Duration, orderedKeys ...string) *Reloadable[time.Duration]
GetReloadableDurationVar registers a not hot-reloadable duration config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableFloat64Var ¶ added in v0.15.9
func GetReloadableFloat64Var(defaultValue float64, orderedKeys ...string) *Reloadable[float64]
GetReloadableFloat64Var registers a hot-reloadable float64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableInt64Var ¶ added in v0.15.9
func GetReloadableInt64Var(defaultValue, valueScale int64, orderedKeys ...string) *Reloadable[int64]
GetReloadableInt64Var registers a hot-reloadable int64 config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableIntVar ¶ added in v0.15.9
func GetReloadableIntVar(defaultValue, valueScale int, orderedKeys ...string) *Reloadable[int]
GetReloadableIntVar registers a hot-reloadable int config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableStringMapVar ¶ added in v0.15.9
func GetReloadableStringMapVar( defaultValue map[string]interface{}, orderedKeys ...string, ) *Reloadable[map[string]interface{}]
GetReloadableStringMapVar registers a hot-reloadable string map config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableStringSliceVar ¶ added in v0.15.9
func GetReloadableStringSliceVar(defaultValue []string, orderedKeys ...string) *Reloadable[[]string]
GetReloadableStringSliceVar registers a hot-reloadable string slice config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func GetReloadableStringVar ¶ added in v0.15.9
func GetReloadableStringVar(defaultValue string, orderedKeys ...string) *Reloadable[string]
GetReloadableStringVar registers a hot-reloadable string config variable
WARNING: keys are being looked up in requested order and the value of the first found key is returned, e.g. asking for the same keys but in a different order can result in a different value to be returned
func (*Reloadable[T]) Load ¶ added in v0.15.9
func (a *Reloadable[T]) Load() T
Load should be used to read the underlying value without worrying about data races
type ValueLoader ¶ added in v0.25.0
type ValueLoader[T any] interface { Load() T }
ValueLoader is an interface that can be used to load a value.
func SingleValueLoader ¶ added in v0.25.0
func SingleValueLoader[T any](v T) ValueLoader[T]
SingleValueLoader returns a ValueLoader that always returns the same value.