Skip to main content

Library to manage configuration using Zookeeper, Etcd, Consul

Project description

https://travis-ci.com/alexferl/distconfig.svg?branch=master Documentation Status

distconfig3

This is a fork of distconfig removing Python 2.7 support as well as six and ujson dependencies.

Library to manage distributed configuration using either ZooKeeper or Etcd or Consul.

Rational

When you have to manage configuration of a given services that are distributed across nodes, you may want to consider using either one of the distributed configuration managers e.g. zookeeper, etcd, consul …, this library goal is to give developers an easy access to configuration stored in the previous backends.

Installation:

To use ZooKeeper as backend you should install distconfig3 using

$ pip install distconfig3[zookeeper]

with etcd:

$ pip install distconfig3[etcd]

with consul:

$ pip install distconfig3[consul]

Usage:

Example using zookeeper as a backend

from kazoo import client

from distconfig import Proxy

client = client.KazooClient()
# The user must call ``KazooClient.start()`` before using this particular
# backend
client.start()

proxy = Proxy.configure(
    'distconfig.backends.zookeeper.ZooKeeperBackend',
    client=client,
)

# config is a read only mapping-like object.
config = proxy.get_config('/distconfig/service_name/config')

print(config['key'])

# Getting nested values works by supplying key seperated by '/' char.
print(config['key/inner'])

# You can assert key value type by using typed get function e.g.
# get_int, get_float, get_unicode, get_bytes ... .
print(config.get_int('key/inner/int_key'))

# Getting a inner config.
print(config.get_config('key/inner/dict_key'))

Development:

Start by installing dependencies

$ pip install -r requirements/dev.txt

To run unit test use tox

$ tox

To run integration test, we recommend you to install docker and then run

$ ./run-tests.sh

The above script will setup docker container for each of the backend and run the integration tests on them.

TODO:

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

distconfig3-1.0.1.tar.gz (11.8 kB view hashes)

Uploaded Source

Built Distribution

distconfig3-1.0.1-py2.py3-none-any.whl (19.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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