Clever/discovery-python

Name: discovery-python

Owner: Clever

Description: Programmatically find service endpoints (i.e. discovery-go for python)

Created: 2016-03-08 23:00:57.0

Updated: 2017-01-10 02:49:53.0

Pushed: 2018-01-11 18:28:30.0

Homepage: null

Size: 12

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

discovery-python

This library programmatically finds endpoints for dependencies. Similar to discovery-go and disocvery-node.

See Service Discovery for more details.

Installation
pip

Assuming discovery v0.1.0 is being installed:

install git+https://github.com/Clever/discovery-python.git@v0.1.0
setup.py
 setuptools import setup

suming discovery v0.1.0 is being installed:
p(

# ...

install_requires=['discovery==0.1.0'],
dependency_links=[
  'https://github.com/Clever/discovery-python/tarball/v0.1.0#egg=discovery-0.1.0'
],

# ...


Usage
rt discovery


stoked_url = discovery.url('stoked', 'thrift')

stoked_host_and_port = discovery.host_port('stoked', 'thrift')

stoked_host = discovery.host('stoked', 'thrift')

stoked_port = discovery.port('stoked', 'thrift')

pt discovery.MissingEnvironmentVariableError as e:
print 'ERROR: Stoked discovery failed: {}.'.format(e)
Development
Publishing a new version
  1. Bump the version in the VERSION file and update the changelog in CHANGES.md.

  2. Merge your changes into master.

  3. Checkout master

  4. Run the publish script:

    blish.sh
    
Implementation Details

Currently, discovery-{go,node,python} looks for environment variables with the following format:

ICE_{SERVICE_NAME}_{EXPOSE_NAME}_{PROTO,HOST,PORT}

These environment variables are autogenerated by our deployment tooling. Three env-vars are created for each app listed in the dependencies section of caller's launch yaml.

For example, if an app lists district-authorizations as a dependency, fab and catapult will generate this env-vars triplet:

ICE_DISTRICT_AUTHORIZATIONS_HTTP_PROTO = "http"
ICE_DISTRICT_AUTHORIZATIONS_HTTP_HOST = "district-authorizations.ops.clever.com"
ICE_DISTRICT_AUTHORIZATIONS_HTTP_PORT = "80"

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.