Real-time detection and loading of dynamic configuration changes from an etcd database to a Python process.
Instead of periodically pooling configurations from a database at fixed intervals, we can utilize etcd database
to watch for changes on specific keys (configs). Whenever new changes occur on these keys, the etcd server will push those changes
to the client, and then react on them accordingly.
Under the hood, it utilizes the python-etcd3 library, which provides a callback method to listen for changes on keys.
- No
boilerplate codeis required. - There is
no needto manually define whichcallback function typeneeds to be bound. - It provides a
JSON deserializerby default, but you can define your own deserialization logic based on your requirements. - It supports
auto-reconnectionwith etcd in case of a connection failure. - You can specify the
number of connection retriesand theretry delay. - It applies
different deserializationmethods to keys if youhave mixed key-valuepairs. - It allows for easy addition of
new observersto perform desired operations on keys. - You can remove the
parse_engineobserver in case ofsimple key-value pairs.
A distributed, reliable key-value store for the most critical data of a distributed system. etcd is a CNCF project.
- Python
- etcd
- Etcd Manager - Optional
Clone the Repository
- Open your terminal or command prompt.
- Change to the directory where you want to clone the project.
- Execute the following command to clone the repository:
git clone https://github.com/faizanfareed/RealtimePyConfigSync.gitNavigate to the project directory:
cd RealtimePyConfigSyncCreate a virtual environment (optional but recommended):
For venv:
python -m venv envFor virtualenv:
virtualenv envActivate the virtual environment:
For Windows:
.\env\Scripts\activateFor Unix/macOS:
source env/bin/activateInstall the project dependencies:
pip install -r requirements.txthttps://hub.docker.com/r/bitnami/etcd/
Once your Docker is up and running, open the app.py module and update the configurations there. After making the necessary changes, run the module.
https://snapcraft.io/install/etcd-manager/ubuntu
License under a MIT License
python-etcd3 license Apache License 2.0.
- Fork, clone or make a pull request to this repository.
- Ask here https://github.com/faizanfareed/RealtimePyConfigSync/discussions