Skip to main content

discovery service client

Project description

Build Status Maintainability codecov PyPI version


discovery-client package sync/async for consul.


Install and update using pip:

pip install -U discovery-client


Async client only

Usage Example

using standard client

from discovery.client import Consul

dc = Consul('localhost', 8500)

Integration with Flask + threading.

import json
import threading

from discovery.client import Consul

from flask import Flask

app = Flask(__name__)
dc = Consul('discovery', 8500)
dc.register('standard-client', 5000)

def health():
    return json.dumps({'status': 'UP'})

def info():
    return json.dumps({'app': 'standard-client'})

def enable_service_registry():
    def probe_discovery_connection():
    thread = threading.Thread(target=probe_discovery_connection)

using asyncio

client using asyncio

import asyncio

from discovery import aioclient

loop = asyncio.get_event_loop()
dc = aioclient.Consul('localhost', 8500, loop)

search_one_task = loop.create_task(dc.find_service('consul'))
search_all_task = loop.create_task(dc.find_services('consul'))


using aiohttp

server using aiohttp + asyncio

import asyncio

from aiohttp import web

from discovery.aioclient import Consul

async def service_discovery(app):
    app.loop.create_task(dc.register('aio-client', 5000))

async def handle_info(request):
    return web.json_response({'app': 'aio-client'})

async def handle_status(request):
    return web.json_response({'status': 'UP'})

app = web.Application()
dc = Consul('discovery', 8500, app.loop)

app.add_routes([web.get('/manage/health', handle_status),
                web.get('/manage/info', handle_info)])
web.run_app(app, host='', port=5000)


Project details

Download files

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

Files for discovery-client, version 0.2.5
Filename, size File type Python version Upload date Hashes
Filename, size discovery_client-0.2.5-py3-none-any.whl (11.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size discovery-client-0.2.5.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page