config

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: AGPL-3.0 Imports: 12 Imported by: 96

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

View Source
const (
	EmbeddedMode       = "embedded"
	MasterMode         = "master"
	MasterSlaveMode    = "master_and_slave"
	SlaveMode          = "slave"
	OffMode            = "off"
	EmbeddedMasterMode = "embedded_master"
)

Rudder server supported config constants

View Source
const DefaultEnvPrefix = "RSERVER"

Variables

This section is empty.

Functions

func ConfigKeyToEnv

func ConfigKeyToEnv(envPrefix, s string) string

ConfigKeyToEnv gets the env variable name from a given config key

func GetBool

func GetBool(key string, defaultValue bool) (value bool)

GetBool gets bool value from config

func GetBoolVar added in v0.15.9

func GetBoolVar(defaultValue bool, orderedKeys ...string) bool

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

func GetFloat64(key string, defaultValue float64) (value float64)

GetFloat64 gets float64 value from config

func GetFloat64Var added in v0.15.9

func GetFloat64Var(defaultValue float64, orderedKeys ...string) float64

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 GetInt

func GetInt(key string, defaultValue int) (value int)

GetInt gets int value from config

func GetInt64

func GetInt64(key string, defaultValue int64) (value int64)

GetInt64 gets int64 value from config

func GetInt64Var added in v0.15.9

func GetInt64Var(defaultValue, valueScale int64, orderedKeys ...string) int64

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

func GetIntVar(defaultValue, valueScale int, orderedKeys ...string) int

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 GetString

func GetString(key, defaultValue string) (value string)

GetString gets string value from config

func GetStringMap

func GetStringMap(key string, defaultValue map[string]interface{}) (value map[string]interface{})

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

func GetStringSlice(key string, defaultValue []string) (value []string)

GetStringSlice gets string slice value from config

func GetStringSliceVar added in v0.15.9

func GetStringSliceVar(defaultValue []string, orderedKeys ...string) []string

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

func GetStringVar(defaultValue string, orderedKeys ...string) string

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 IsSet

func IsSet(key string) bool

IsSet checks if config is set for a key

func MustGetInt

func MustGetInt(key string) (value int)

MustGetInt gets int value from config or panics if the config doesn't exist

func MustGetString

func MustGetString(key string) (value string)

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

func Reset

func Reset()

Reset resets the default, singleton config instance. Shall only be used by tests, until we move to a proper DI framework

func Set

func Set(key string, value interface{})

Set override existing config

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 New

func New(opts ...Opt) *Config

New creates a new config instance

func (*Config) ConfigFileUsed added in v0.25.0

func (c *Config) ConfigFileUsed() (string, error)

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

func (c *Config) DotEnvLoaded() error

DotEnvLoaded returns an error if there was an error loading the .env file. It returns nil otherwise.

func (*Config) GetBool

func (c *Config) GetBool(key string, defaultValue bool) (value bool)

GetBool gets bool value from config

func (*Config) GetBoolVar added in v0.15.9

func (c *Config) GetBoolVar(defaultValue bool, orderedKeys ...string) bool

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

func (c *Config) GetFloat64(key string, defaultValue float64) (value float64)

GetFloat64 gets float64 value from config

func (*Config) GetFloat64Var added in v0.15.9

func (c *Config) GetFloat64Var(defaultValue float64, orderedKeys ...string) float64

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) GetInt

func (c *Config) GetInt(key string, defaultValue int) (value int)

GetInt gets int value from config

func (*Config) GetInt64

func (c *Config) GetInt64(key string, defaultValue int64) (value int64)

GetInt64 gets int64 value from config

func (*Config) GetInt64Var added in v0.15.9

func (c *Config) GetInt64Var(defaultValue, valueScale int64, orderedKeys ...string) int64

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

func (c *Config) GetIntVar(defaultValue, valueScale int, orderedKeys ...string) int

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) GetString

func (c *Config) GetString(key, defaultValue string) (value string)

GetString gets string value from config

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

func (c *Config) GetStringSlice(key string, defaultValue []string) (value []string)

GetStringSlice gets string slice value from config

func (*Config) GetStringSliceVar added in v0.15.9

func (c *Config) GetStringSliceVar(defaultValue []string, orderedKeys ...string) []string

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

func (c *Config) GetStringVar(defaultValue string, orderedKeys ...string) string

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) IsSet

func (c *Config) IsSet(key string) bool

IsSet checks if config is set for a key

func (*Config) MustGetInt

func (c *Config) MustGetInt(key string) (value int)

MustGetInt gets int value from config or panics if the config doesn't exist

func (*Config) MustGetString

func (c *Config) MustGetString(key string) (value string)

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

func (*Config) Set

func (c *Config) Set(key string, value interface{})

Set override existing config

type Opt

type Opt func(*Config)

func WithEnvPrefix

func WithEnvPrefix(prefix string) Opt

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.

Jump to

Keyboard shortcuts

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