Vanilla (https://github.com/cablehead/vanilla) Python client for Consul (http://www.consul.io/)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
tests
vanilla
.gitignore
.gitmodules
MANIFEST.in
README.rst
requirements.txt
setup.py
tox.ini

README.rst

Vanilla client for Consul.io

This is an adaptor/plugin for Vanilla based on the python-consul library.

Usage is the same as the standard API except that all API calls return a Vanilla pipe, which can be recv'ed on to receive the Consul response.

Example

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

Installation

pip install vanilla.consul