EtcdConfig
This configuration loads the configuration data from an etcd directory, sub directories are also read as a dict
.
Library python-etcd is required (pip install python-etcd)
When a key is created/delete/updated via etcd a callback will be notified and the value managed by EtcdConfig
will be updated.
etcdctl set /appname/config/database/host localhost
>> localhost
etcdctl set /appname/config/database/port 1234
>> 1234
# main.py
import etcd
from central.config.etcd import EtcdConfig
client = etcd.Client()
config = EtcdConfig(client, '/appname/config')
config.load()
print(config.get('database'))
print(config.get('database.host'))
print(config.get('database.port'))
python main.py
>> {'port': '1234', 'host': 'localhost'}
>> localhost
>> 1234