This service provides a REST interface for querying for the list of hosts that belong to a given service in microservice infrastructure.
Host information is written to and read from backend store (DynamoDB by default). This project relies on the following libraries:
Flask (web-framework)
Flask-Cache (for caching and reusing results for GET requests)
If the last heartbeat was not performed in the last HOST_TTL seconds, discovery service will remove host from backend storage. Default value is 600 (10 minutes).
CACHE_TTL
Flask cache expiration in seconds, discovery calls BACKEND_STORAGE to fill the cache.
This cache is used for hosts retrieval by service or service repo.
Default value is 30 seconds.
BACKEND_STORAGE
Type of the backend storage used in discovery service. Supported values are: DynamoDB, InMemory, InFile.
By default DynamoDB backend is used.
CACHE_TYPE
Supported values 'simple' or 'null'. Default value is 'null' which effectively turn flask caching off.
APPLICATION_DIR
Application directory.
APPLICATION_ENV
Environment discovery service runs in, e.g., development or production. Default value is development.
DEBUG
If debug mode is used. Default value is true.
LOG_LEVEL
Set logging level. Default value is DEBUG.
PORT
Port flask app using. Default value is 8080.
DYNAMODB_TABLE_HOSTS
Used only in case of DynamoDB backend.
DYNAMODB_URL
Used only for development in case of DynamoDB backend running locally.
DYNAMODB_CREATE_TABLES_IN_APP
Used for creating DynamoDB table, useful only in case DynamoDB backend storage used.
(required, string) name of the service metadata is queried for.
On successful response, response body will be in the following JSON format:
{
"env": "...",
"hosts": [],
"service": "..."
}
env
(required, string) environment discovery service runs in, e.g., development or production.
hosts
(required, object) list of non expired hosts (hosts that last checked in to discovery service in the last HOST_TTL period).
Each host is in the following JSON format:
Returns list of non expired hosts for :service_repo_name (query based on secondary index, for example, DynamoDB GSI).
Format is the same as query based on service.
(required, string) AWS availability zone that the host is running in. You
can provide arbitrary but the same value for all hosts if zone aware stats/routing
is not required. If you use non AWS backend storage currently you have to provide az
anyway, you can use some fixed predefined value for all hosts.
region
(required, string) AWS region that the host is running in.
instance_id
(required, string) AWS instance_id of the host.
canary
(optional, boolean) Set to true if host is a canary instance, used by Envoy.
load_balancing_weight:
(optional, integer) Load balancing weight is used by Envoy for weighted routing.
Values must be an integer between 1 and 100.