pydisconf

Python client of disconf


Keywords
configure, Disconfig
License
MIT
Install
pip install pydisconf==0.1.6.dev1

Documentation

pydisconf

pydisconf是百度配置中心Disconf的Python客户端实现,支持PyPi安装:

pip install pydisconf

快速使用方法:

在项目目录下增加./disconf/disconf.properties,内容:

# Disconf Web Api的地址
disconf.conf_server_host=http://127.0.0.1:8080
#版本,在Disconf中创建时提供
disconf.version=1_0_0_0
#App名称,在Disconf中创建时提供
disconf.app=disconf_demo
#运行环境,在Disconf中创建时提供
disconf.env=rd
#本地文件缓存目录,如果没有则不会在本地缓存
disconf.user_define_download_dir=./

代码中:

import pydisconf
...
@pydisconf.config_file('autoconfig', def_val='''\
auto=false
rate=12
''')
def get_autoconfig(key):
    pass
...
#这一句必须在使用配置数据之前调用
pydisconf.start()
...
get_autoconfig('auto')

具体例子参见:demo.py

下一步开发计划:

  1. 增加事件回调函数,运行客户代码处理配置更新事件
  2. 增加ZK主备切换处理

欢迎骚扰: qq: 346294202 email: sillyemperor@163.com