viniciuschiele / central

A dynamic configuration library. https://viniciuschiele.gitbooks.io/central
MIT License
3 stars 2 forks source link
archaius configuration configuration-file configuration-management dynamic dynamodb etcd filesystem mongodb netflix polling s3 storage

Central


Central is a configuration library for Python inspirited by Netflix Archaius <https://github.com/Netflix/archaius>_ that provides APIs to access and utilize properties that can change dynamically at runtime.

|Coverage| |Travis|

Features

Quick Start

Assuming you are using requests library to access an external web service, you may want to change the max number of connections to tune your application, using Central you can do it without having to restart your application.

.. code-block:: python

import requests
import requests.adapters

from central.config.file import FileConfig
from central.property import PropertyManager

config = FileConfig('./config.json').reload_every(600)  # 10 minutes in seconds
config.load()

properties = PropertyManager(config)
pool_maxsize = properties.get_property('pool_maxsize').as_int(5)

adapter = requests.adapters.HTTPAdapter(pool_maxsize=pool_maxsize.get())
session = requests.Session()
session.mount('http://', adapter)

@pool_maxsize.on_updated
def pool_maxsize_updated(value):
    adapter = requests.adapters.HTTPAdapter(pool_maxsize=value)
    session.mount('http://', adapter)

response = session.get('http://date.jsontest.com')

Get It Now

::

$ pip install central

Requirements

Central has no external dependencies outside of the Python standard library.

Roadmap

License

MIT licensed. See the bundled LICENSE <https://github.com/viniciuschiele/central/blob/master/LICENSE>_ file for more details.

.. |Coverage| image:: https://codecov.io/github/viniciuschiele/central/coverage.svg :target: https://codecov.io/github/viniciuschiele/central

.. |Travis| image:: https://travis-ci.org/viniciuschiele/central.svg :target: https://travis-ci.org/viniciuschiele/central