Metadata-Version: 2.4
Name: etcd-dynamic-config
Version: 0.2.2
Summary: A Python library for managing etcd-based configurations with caching and real-time updates
Author-email: Anton Irshenko <a_irshenko@example.com>
Maintainer-email: Anton Irshenko <a_irshenko@example.com>
License: MIT
Project-URL: Homepage, https://github.com/ton5169/etcd-dynamic-config
Project-URL: Documentation, https://github.com/ton5169/etcd-dynamic-config#readme
Project-URL: Repository, https://github.com/ton5169/etcd-dynamic-config
Project-URL: Issues, https://github.com/ton5169/etcd-dynamic-config/issues
Project-URL: Changelog, https://github.com/ton5169/etcd-dynamic-config/blob/main/CHANGELOG.md
Keywords: etcd,configuration,cache,watcher,async
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: etcd3-py==0.1.6
Requires-Dist: ecs-logging==2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: coverage>=7.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: isort>=5.10.0; extra == "dev"
Requires-Dist: flake8>=4.0.0; extra == "dev"
Requires-Dist: mypy>=0.950; extra == "dev"
Requires-Dist: sphinx>=4.0.0; extra == "dev"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=4.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"

# etcd-dynamic-config

Python library for managing etcd-based configurations with caching and real-time updates.

## Installation

```bash
pip install etcd-dynamic-config
```

## Quick Start

### Basic Usage

```python
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

```python
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:

```bash
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
