香草蟒蛇领事馆客户端
vanilla.consul的Python项目详细描述
这是基于python-consul库的Vanilla的适配器/插件。
用法与standard API相同,只是所有api调用都返回 香草烟斗,可以recv'打开以接收consur响应。
示例
h=vanilla.Hub()c=h.consul()classConfig(object):passconfig=Config()@h.spawndefmonitor():# register our servicec.agent.service.register('foo',service_id='foo:1',ttl='10s').recv()@h.spawndefkeepalive():whileTrue:# ping our service's health check every 5sc.health.check.ttl_pass('service:foo:1').recv()h.sleep(5000)# maintain our internal configuration state with all available nodes# providing the foo serviceindex=NonewhileTrue:index,nodes=c.health.service('foo',index=index,passing=True).recv()config.nodes=[node['Service']['ID']fornodeinnodes]# make use of config.nodes
安装
pip install vanilla.consul