Backends¶
Base class¶
- class distconfig.backends.base.BaseBackend(parser=<built-in function loads>, logger=<logging.Logger object at 0x7f0853171b90>)¶
Base abstract backend class.
Backend implementation should inherit and implement get_raw method.
Parameters: - parser – Callable that accept a string and parse it, default: ujson.loads.
- logger – logging.Logger` instance.
- add_listener(callback)¶
Add callback to be called when data change in the backend.
If the same callback is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.
Parameters: callback – Callable that accept one argument the new data.
- get(path)¶
Get parsed path value in backend.
Path: key in the backend. Returns: path value parsed.
- get_raw(path)¶
Get path value from backend as it is.
Path: key in the backend. Returns: path value as saved in backend or None if not found in backend.
- remove_listener(callback)¶
Remove previously added callback.
If callback had been added more than once, then only the first occurrence will be removed.
Parameters: callback – Callable as with :meth: add_listener. Raises ValueError: In case callback was not previously registered.
Existing backends¶
The current backends exist out of the box:
- class distconfig.backends.consul.ConsulBackend(client, execution_context=<distconfig.backends.execution_context.ThreadingExecutionContext object at 0x7f0853180e90>, **kwargs)¶
Consul backend implementation.
Parameters: - client – Instance of consul.Consul.
- execution_context – Instance of distconfig.backends.execution_context.ExecutionContext