{"id":13647394,"url":"https://github.com/lyft/discovery","last_synced_at":"2025-04-22T02:31:29.552Z","repository":{"id":66215728,"uuid":"65575590","full_name":"lyft/discovery","owner":"lyft","description":"This service provides a REST interface for querying for the list of hosts that belong to all microservices.","archived":true,"fork":false,"pushed_at":"2024-04-30T20:59:28.000Z","size":58,"stargazers_count":184,"open_issues_count":5,"forks_count":43,"subscribers_count":139,"default_branch":"master","last_synced_at":"2024-11-09T21:36:44.692Z","etag":null,"topics":["lyft"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lyft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-12T18:34:59.000Z","updated_at":"2024-04-30T21:02:57.000Z","dependencies_parsed_at":"2024-08-02T01:27:02.037Z","dependency_job_id":"25da562d-3d08-45e7-bf31-a8bef785c720","html_url":"https://github.com/lyft/discovery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fdiscovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fdiscovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fdiscovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fdiscovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyft","download_url":"https://codeload.github.com/lyft/discovery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250163653,"owners_count":21385281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lyft"],"created_at":"2024-08-02T01:03:32.288Z","updated_at":"2025-04-22T02:31:29.263Z","avatar_url":"https://github.com/lyft.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"⚠️ This repository has been archived and is no longer accepting contributions ⚠️\n\n# Discovery\n\nThis service provides a REST interface for querying for the list of hosts that belong to a given service in microservice infrastructure.\nHost information is written to and read from backend store (DynamoDB by default). This project relies on the following libraries:\n* Flask (web-framework)\n* Flask-Cache (for caching and reusing results for GET requests)\n* Pynamodb (for reading/writing DynamoDB data)\n\nAlso check [requirements.txt](https://github.com/lyft/discovery/blob/master/requirements.txt) for other dependencies.\n\n## Discovery service settings\nDiscovery service settings are controlled by [environment variables](https://github.com/lyft/discovery/blob/master/app/settings.py).\n\n* HOST_TTL\n  * 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).\n* CACHE_TTL\n  * Flask cache expiration in seconds, discovery calls BACKEND_STORAGE to fill the cache.\n  This cache is used for hosts retrieval by [service](#get-v1registrationservice) or [service repo](#get-v1registrationreposervice_repo_name).\n  Default value is 30 seconds.\n* BACKEND_STORAGE\n  * Type of the backend storage used in discovery service. Supported values are: DynamoDB, InMemory, InFile.\n  By default DynamoDB backend is used.\n* CACHE_TYPE\n  * Supported values 'simple' or 'null'. Default value is 'null' which effectively turn flask caching off.\n* APPLICATION_DIR\n  * Application directory.\n* APPLICATION_ENV\n  * Environment discovery service runs in, e.g., development or production. Default value is development.\n* DEBUG\n  * If debug mode is used. Default value is true.\n* LOG_LEVEL\n  * Set logging level. Default value is DEBUG.\n* PORT\n  * Port flask app using. Default value is 8080.\n* DYNAMODB_TABLE_HOSTS\n  * Used only in case of DynamoDB backend.\n* DYNAMODB_URL\n  * Used only for development in case of DynamoDB backend running locally.\n* DYNAMODB_CREATE_TABLES_IN_APP\n  * Used for creating DynamoDB table, useful only in case DynamoDB backend storage used.\n\n## API\n### GET /v1/registration/:service\nReturns metadata for the given `:service`.\n\n* service\n  * *(required, string)* name of the service metadata is queried for.\n\nOn successful response, response body will be in the following JSON format:\n```json\n{\n    \"env\": \"...\",\n    \"hosts\": [],\n    \"service\": \"...\"\n}\n```\n* env\n  * *(required, string)* environment discovery service runs in, e.g., development or production.\n* hosts\n  * *(required, object)* list of non expired hosts (hosts that last checked in to discovery service in the last HOST_TTL period).\n  Each host is in the following JSON format:\n\n    ```json\n    {\n        \"ip_address\": \"...\",\n        \"last_check_in\": \"...\",\n        \"port\": 9211,\n        \"revision\": \"...\",\n        \"service\": \"...\",\n        \"service_repo_name\": \"...\",\n        \"tags\": {}\n    }\n    ```\n  * ip_address\n    * *(required, string)* ip address of the host.\n  * last_check_in\n    * *(required, string)* heartbeat timestamp converted to string, last time host registered with discovery service.\n  * port\n    * *(required, integer)* port on which the host expects connections, Envoy will connect to this port.\n  * revision\n    * *(required, string)* service SHA running on the host.\n  * service\n    * *(required, string)* service name.\n  * service_repo_name\n    * *(required, string)* service repo, used for selecting hosts based on the service_repo (can be empty if not set).\n  * tags\n    * *(required, object)* see tags [here](#tags-json).\n* service\n  * *(required, string)* service name.\n\n### GET /v1/registration/repo/:service_repo_name\nReturns list of non expired hosts for `:service_repo_name` (query based on secondary index, for example, DynamoDB GSI).\nFormat is the same as [query based on service](#get-v1registrationservice).\n\n### POST /v1/registration/:service\nRegisters a host with a service. Response body does not contain any data.\n\n* service\n  * *(required, string)* Service for which operation is performed.\n\nRequest params:\n* ip\n  * *(required, string)* ip address of the host.\n* service_repo_name\n  * *(optional, string)* service repository name, can be used for quick search.\n* port\n  * *(required, integer)* port on which the host expects connections, Envoy will connect to this port.\n* revision\n  * *(required, string)* SHA of the revision the service is currently running.\n* tags\n  * *(required, object)* JSON in the following [format](#tags-json).\n\n### DELETE /v1/registration/:service/:ip_address\nDeletes the host for the given `service` with `ip_address`.\nReturns response code 400 if no `service`/`ip_address` entity exists.\n\n* service\n  * *(required, string)* name of the service metadata is queried for.\n* ip\n  * *(required, string)* ip address of the host.\n\n### POST /v1/loadbalancing/:service/:ip_address\nUpdates the weight of hosts for load balancing purposes.\n\n* service\n  * *(required, string)* Service name for which weight is updated.\n* ip_address\n  * *(optional, string)* IP address of the host for which weight is updated.\n  If not given, *all* hosts for the given service will have their weights updated.\n\nRequest params:\n* load_balancing_weight\n  * *(required, integer)* Host weight, an integer between 1 and 100.\n\n#### Tags JSON\n```json\n  {\n     \"az\": \"...\",\n     \"region\": \"...\",\n     \"instance_id\": \"...\",\n     \"canary\": false,\n     \"load_balancing_weight\": 1\n  }\n```\n\n* az\n  * *(required, string)* AWS availability zone that the host is running in. You\n  can provide arbitrary but the same value for all hosts if zone aware stats/routing\n  is not required. If you use non AWS backend storage currently you have to provide `az`\n  anyway, you can use some fixed predefined value for all hosts.\n* region\n  * *(required, string)* AWS region that the host is running in.\n* instance_id\n  * *(required, string)* AWS instance_id of the host.\n* canary\n  * *(optional, boolean)* Set to true if host is a canary instance, used by Envoy.\n* load_balancing_weight:\n  * *(optional, integer)* Load balancing weight is used by Envoy for weighted routing.\n  Values must be an integer between 1 and 100.\n\n## Main Classes\n- [app/routes/api.py](https://github.com/lyft/discovery/blob/master/app/routes/api.py)\n - defines the HTTP routes for service registration\n- [app/resources/api.py](https://github.com/lyft/discovery/blob/master/app/resources/api.py)\n - the entry point for service registration GETs and POSTs\n- [app/services/host.py](https://github.com/lyft/discovery/blob/master/app/services/host.py)\n - contains the business logic (e.g. caching, input validation, etc) for service registration GETS and POSTs\n- [app/models/host.py](https://github.com/lyft/discovery/blob/master/app/models/host.py)\n - The pynamo model for service registration information for a host\n\n## Unit Testing\n*Note* currently it's not working on public repository without tweaking (there is an opened issue for this)\nTo run all unit tests, run `make test_unit`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyft%2Fdiscovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyft%2Fdiscovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyft%2Fdiscovery/lists"}