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.4.tar.gz (16.9 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.4-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: etcd_dynamic_config-0.2.4.tar.gz
  • Upload date:
  • Size: 16.9 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.4.tar.gz
Algorithm Hash digest
SHA256 be9d48df8532dca806b9b022fe44ac1c67d76a9c0ba5872ae83629b4229650ac
MD5 ab71eadd5fccacc6bd540f5831ce0773
BLAKE2b-256 10d3aab4f69cb4543de9027277daf8c4de63257d6433bd69e8bc5327dfc23392

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for etcd_dynamic_config-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 094685cb28ef4c3244e6d6afa2bccff593545bd7583024411ac81c506aeedd23
MD5 a15c7bbc9dd4d5f342e62c3438c1e8f7
BLAKE2b-256 083771a2771dc28b6f9b68317ec483d83448e495c4df09e23fcced614d45e559

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