Vanilla Python客户端,用于Consul.io
项目描述
这是一个基于Vanilla的适配器/插件,基于python-consul库。
使用方式与标准API相同,但所有API调用都返回一个Vanilla管道,该管道可以被recv读取以接收Consul响应。
示例
h = vanilla.Hub()
c = h.consul()
class Config(object):
pass
config = Config()
@h.spawn
def monitor():
# register our service
c.agent.service.register(
'foo', service_id='foo:1', ttl='10s').recv()
@h.spawn
def keepalive():
while True:
# ping our service's health check every 5s
c.health.check.ttl_pass('service:foo:1').recv()
h.sleep(5000)
# maintain our internal configuration state with all available nodes
# providing the foo service
index = None
while True:
index, nodes = c.health.service(
'foo', index=index, passing=True).recv()
config.nodes = [node['Service']['ID'] for node in nodes]
# make use of config.nodes
安装
pip install vanilla.consul
项目详情
关闭
vanilla.consul-0.4.7.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3d863d1369ad67da2f5a282ec60734955e84198a4edbaa8329b83883b90267f7 |
|
MD5 | 6192b6b9df7e6087a5f966d78516f824 |
|
BLAKE2b-256 | 0929b3e56b5f0630cd9169ef1c99649721a74fbf71baec33f8e5b845783373d9 |