使用zookeeper、etcd、consul管理配置的库

distconfig的Python项目详细描述


https://travis-ci.org/deliveryhero/distconfig.svg?branch=masterDocumentation Status

distconfig

使用ZooKeeperEtcdConsul

合理

当您必须管理跨节点分布的给定服务的配置时,您可能需要 要考虑使用其中一个分布式配置管理器,例如zookeeper、etcd、consul…,请执行以下操作 库的目标是让开发人员能够方便地访问存储在以前后端中的配置。

安装:

要使用zookeeper作为后端,您应该使用distconfig

$ pip install distconfig[zookeeper]

使用etcd

$ pip install distconfig[etcd]

使用consul

$ pip install distconfig[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 requirements/base.txt

要运行单元测试,请使用tox

$ tox

要运行集成测试,建议您安装docker,然后运行

$ ./run-tests.sh

上面的脚本将为每个后端设置Docker容器 并对它们运行集成测试。

待办事项:

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

推荐PyPI第三方库


热门话题
java如何修改打印板?   java Spring批处理JdbcCursorItemReader还是RepositoryItemReader?   java如何在JTable Swing中增加标题列的字体?   java在数组方面遇到问题,导致表达式非法启动   java如何为maven pom的某些部分关闭Eclipse代码格式化程序。xml   java Dropwizard登录代码   java Jersey 2.22:客户端的默认连接超时是多少?   java无法自动连接字段:javax。sql。数据来源   如何从java中的行列表中获取单词列表?   java JDBC批量更新和处理异常?   计算大根:bigdecimal/java   java如何在JavaCC语法中提到trycatch块   javasocket。getInetAddress()不返回任何内容   oracle SQL开发人员错误无法找到Java虚拟机   java我如何计算和显示未来5年每一年的投资价值   java如何关闭浏览器选项卡?   java如何在showMessageDialog中打印双2D数组?   java从站点抓取播放列表URL?   selenium中的java点击css按钮