Configuration Module¶
This module contains functionality to read configuration values from different sources and to retrieve or inject them.
ConfigurationManager()
¶
ConfigurationManager is responsible for managing different configuration sources by merging the different values and offering a uniform api.
get(path, type, default=None)
¶
Retrieve a configuration value by path and type, with optional coercion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the configuration value, e.g. "database.host". |
required |
type
|
Type[T]
|
The expected type. |
required |
default
|
Optional[T]
|
The default value to return if the path is not found. |
None
|
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
The configuration value coerced to the specified type, or the default value if not found. |
ConfigurationSource()
¶
Bases: ABC
A configuration source is a provider of configuration data.
load()
abstractmethod
¶
return the configuration values of this source as a dictionary.
EnvConfigurationSource()
¶
YamlConfigurationSource(file)
¶
inject_value(key, default=None)
¶
Decorator to inject a configuration value into a method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to inject. |
required |
default
|
The default value to use if the key is not found. |
None
|