Skip to main content

Vanilla Python client for Consul.io

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vanilla.consul-0.4.7.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file vanilla.consul-0.4.7.tar.gz.

File metadata

File hashes

Hashes for vanilla.consul-0.4.7.tar.gz
Algorithm Hash digest
SHA256 3d863d1369ad67da2f5a282ec60734955e84198a4edbaa8329b83883b90267f7
MD5 6192b6b9df7e6087a5f966d78516f824
BLAKE2b-256 0929b3e56b5f0630cd9169ef1c99649721a74fbf71baec33f8e5b845783373d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page