This library programmatically finds endpoints for dependencies. Similar to discovery-go and disocvery-node.
See Service Discovery for more details.
Assuming discovery v0.1.0 is being installed:
pip install git+https://github.com/Clever/discovery-python.git@v0.1.0
from setuptools import setup
# Assuming discovery v0.1.0 is being installed:
setup(
# ...
install_requires=['discovery==0.1.0'],
dependency_links=[
'https://github.com/Clever/discovery-python/tarball/v0.1.0#egg=discovery-0.1.0'
],
# ...
)
import discovery
try:
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')
clever_com_url = discovery.external_url('clever.com')
except discovery.MissingEnvironmentVariableError as e:
print 'ERROR: Stoked discovery failed: {}.'.format(e)
-
Bump the version in the
VERSION
file and update the changelog inCHANGES.md
. -
Merge your changes into
master
. -
Checkout
master
-
Run the publish script:
./publish.sh
Currently, discovery-{go,node,python}
looks for environment variables with the following format:
SERVICE_{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:
SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PROTO = "http"
SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_HOST = "district-authorizations.ops.clever.com"
SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PORT = "80"