Skip to main content

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.2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

etcd_dynamic_config-0.2.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file etcd_dynamic_config-0.2.2.tar.gz.

File metadata

  • Download URL: etcd_dynamic_config-0.2.2.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

Hashes for etcd_dynamic_config-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6332ab4aeab3efec6067cb0c4ead6d93472f22a3c49b9739b9c261b5ec70be0f
MD5 2f2f5a286a68cd1236268e718b5f0d11
BLAKE2b-256 b10da90d552c2b4129029deb87106bdf51b8d6eb5bd1b7df746b190f04079530

See more details on using hashes here.

File details

Details for the file etcd_dynamic_config-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for etcd_dynamic_config-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c184f9f96efba1ef7572d49f24bd8e1fb1bb40b3c1a8c522fcfe357ee3fb3d5b
MD5 99fd3ce8909bc009641f90c057dd9207
BLAKE2b-256 ad923df1a2620f109fca7c715c3cd12484788aed7ebcee02eb91b02035ea2d9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page