使用Zookeeper、Etcd、CONSUR管理配置的库

distconfig3的Python项目详细描述


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

分布式配置3

这是一个distconfig的分支,删除了对python2.7的支持以及6个 和ujson依赖关系。在

使用ZooKeeperEtcd或{a6}。在

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容器 并对它们运行集成测试。在

待办事项:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在验证检查中改进构建器模式?   java如何定义一个依赖项来获取快照?   java Javafx webview在运行时不显示dashplotly应用程序   java Android kotlin单元测试用例。。?   java Android:SurfaceView,为什么要使用不同的线程   Android/Java“org.apache.http.ProtocolException”,http头应答有问题   反射如何确定类成员是否是静态的以及Java中的字段   java设置EditText以接受双值的问题   类加载器如何使用类加载器将jar从我的网站加载到java应用程序的脚本中   java GWT HTMLTable colaspan功能   java无法删除/重命名文件   java Navigableset vs Navigablemap   php中java加密方法的转换   java为什么加载我的共享对象文件会在Netbeans 8.2中出现“未满足链接”错误?   java JAXRS CXF异常包装   java程序在If语句之后执行Else语句   java将对象转换为JAXBElement<Object>