Documentation ¶
Overview ¶
Package provider defines a built-in configuration providers that are automatically registered by usrv.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvVars ¶
type EnvVars struct{}
EnvVars implements a configuration provider that fetches configuration values from the environment variables associated with the currently running process.
func (*EnvVars) Get ¶
Get returns a map containing configuration values associated with a particular path.
To match the standard envvar form, the path is first normalized by converting it to uppercase and then replacing any path separators with an underscore while also trimming any leading separators.
The provider then scans the process envvars and selects the ones whose names begin with the normalized path. The configuration map keys are built by stripping the path prefix from any matched envvars, lowercasing the remaining part of the envvar name and replacing any underscores with the path separator.
For example, given the path "/redis/MASTER" the following envvars would be matched as configuration options:
- REDIS_MASTER_SERVICE_HOST=10.0.0.11
- REDIS_MASTER_PORT_6379_TCP=tcp://10.0.0.11:6379
The above options would yield the following configuration map:
{ "service/host": "10.0.0.11", "port/6379/tcp": "tcp://10.0.0.11:6379", }