A Python library for managing etcd-based configurations with caching and real-time updates
Project description
etcd-dynamic-config
Python library for managing etcd-based configurations with caching and real-time updates.
Installation
pip install etcd-dynamic-config
Quick Start
Basic Usage
from etcd_dynamic_config import BaseEtcdClient
# Create client
client = BaseEtcdClient(
endpoint=os.getenv("EtcdSettings__HostName"),
username=os.getenv("EtcdSettings__UserName"),
password=os.getenv("EtcdSettings__Password"),
root_key=os.getenv("EtcdSettings__RootKey", "/APPS/ControlUnit"),
use_snake_case=True, # transform values that we got under rootkey to python format
auto_discover_keys=True, # search those values, if stated False you should redifine _build_etcd_key_map method
)
# Get configuration
config = client.get_config()
# Use values
api_url = config.get('categorization_api_url')
db_dsn = config.get('postgres_dsn')
Async Usage
import asyncio
from etcd_dynamic_config import EtcdConfig, ControlUnitEtcdClient
async def main():
client = ControlUnitEtcdClient()
config_manager = EtcdConfig(client=client)
await config_manager.start()
configs = await config_manager.get_all_configs()
await config_manager.stop()
asyncio.run(main())
Environment Variables
Set these to configure etcd connection:
export EtcdSettings__HostName="http://localhost:2379"
export EtcdSettings__UserName="username"
export EtcdSettings__Password="password"
export EtcdSettings__RootKey="/APPS/ControlUnit"
Features
- In-memory caching for fast access
- Real-time updates via etcd watch
- Automatic type coercion (bool, int, float, tuple)
- Snake case conversion (CamelCase → snake_case)
- Environment variable fallback
- Thread-safe operations
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
etcd_dynamic_config-0.2.3.tar.gz
(16.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file etcd_dynamic_config-0.2.3.tar.gz.
File metadata
- Download URL: etcd_dynamic_config-0.2.3.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be79590083fd9c39b5dbc57631d75039a39400813e7f5308d48f7617c57d4cad
|
|
| MD5 |
1b77cc652ff3e181e5a4101caa0e5f43
|
|
| BLAKE2b-256 |
c16bdecc778fd93b77d22cc7fe652aceb7794e30c6523b627075c7f20159b2b2
|
File details
Details for the file etcd_dynamic_config-0.2.3-py3-none-any.whl.
File metadata
- Download URL: etcd_dynamic_config-0.2.3-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb5691fec0ffb4a6908c397bad4b029fd324cb5f320d0131020823af9d0794f4
|
|
| MD5 |
1ba7024a2174075502f2b3e8e6dd63fb
|
|
| BLAKE2b-256 |
23606a7b26bed1a992766a964a33937381cddbd29a6b8bf8fe72a26f468aab75
|