跳转到主要内容

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 (2.7 kB 查看哈希)

上传时间:

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面