ConfigDependency

class gafaelfawr.dependencies.config.ConfigDependency

Bases: object

Provides the configuration as a dependency.

We want a production deployment to default to one configuration path, but allow that path to be overridden by the test suite and, if the path changes, to reload the configuration (which allows sharing the same set of global singletons across multiple tests). Do this by loading the config dynamically when it’s first requested and reloading it whenever the configuration path is changed.

Methods Summary

__call__()

Load the configuration if necessary and return it.

config()

Load the configuration if necessary and return it.

set_config_path(path)

Change the configuration path and reload the config.

Methods Documentation

async __call__()

Load the configuration if necessary and return it.

Return type:

Config

config()

Load the configuration if necessary and return it.

This is equivalent to using the dependency as a callable except that it’s not async and can therefore be used from non-async functions.

Return type:

Config

set_config_path(path)

Change the configuration path and reload the config.

Parameters:

path (Path) – The new configuration path.

Return type:

None