使用Zookeeper、Etcd、CONSUR管理配置的库
distconfig3的Python项目详细描述
分布式配置3
这是一个distconfig的分支,删除了对python2.7的支持以及6个 和ujson依赖关系。在
eh3理性>
当您必须管理跨节点分布的给定服务的配置时,您可能需要 要考虑使用分布式配置管理器(例如zookeeper、etcd、Consult…),请使用 库的目标是让开发人员能够轻松地访问存储在以前后端中的配置。在
安装:
要使用ZooKeeper作为后端,您应该使用安装distconfig3
$ pip install distconfig3[zookeeper]
使用etcd:
^{pr2}$使用consur:
$ pip install distconfig3[consul]
用法:
使用zookeeper作为后端的示例
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'))
开发:
从安装依赖项开始
$ pip install -r requirements/dev.txt
运行单元测试使用tox
$ tox
要运行集成测试,建议您安装docker,然后运行
$ ./run-tests.sh
上面的脚本将为每个后端设置docker容器 并对它们运行集成测试。在
待办事项:
- 添加文件作为后端(使用https://pypi.python.org/pypi/watchdog)
- 项目
标签: