{"id":27786282,"url":"https://github.com/clever/discovery-go","last_synced_at":"2025-04-30T15:58:58.012Z","repository":{"id":35864607,"uuid":"40149694","full_name":"Clever/discovery-go","owner":"Clever","description":"Programmatically find services","archived":false,"fork":false,"pushed_at":"2025-04-24T00:29:47.000Z","size":86,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-04-24T01:27:04.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clever.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null}},"created_at":"2015-08-03T21:51:29.000Z","updated_at":"2025-04-24T00:29:51.000Z","dependencies_parsed_at":"2025-04-24T01:33:54.647Z","dependency_job_id":null,"html_url":"https://github.com/Clever/discovery-go","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fdiscovery-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fdiscovery-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fdiscovery-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clever%2Fdiscovery-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clever","download_url":"https://codeload.github.com/Clever/discovery-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251737796,"owners_count":21635675,"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":[],"created_at":"2025-04-30T15:58:57.244Z","updated_at":"2025-04-30T15:58:57.990Z","avatar_url":"https://github.com/Clever.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discovery-go\n\nThis library programmatically finds endpoints for dependencies. Similar to [discovery-node](https://github.com/Clever/discovery-node) and [disocvery-python](https://github.com/Clever/discovery-python).\n\n\nSee [Service Discovery](https://clever.atlassian.net/wiki/spaces/ENG/pages/116686857/Discovery) for more details.\n\n\n## API\n\n[Godoc Documentation](http://godoc.org/github.com/Clever/discovery-go)\n\n### Examples\n\n```go\ngearmanAdminURLString, err := discovery.URL(\"gearman-admin\", \"http\")\nif err != nil {\n    log.Fatal(\"ERROR: \" + err.Error())\n}\n\nstokedHostPort, err := discovery.HostPort(\"stoked\", \"thrift\")\nif err != nil {\n    logger.Fatal(\"ERROR: \" + err.Error())\n}\n\nstokedHost, err := discovery.Host(\"stoked\", \"thrift\")\nif err != nil {\n    logger.Fatal(\"ERROR: \" + err.Error())\n}\n\nstokedPort, err := discovery.Port(\"stoked\", \"thrift\")\nif err != nil {\n    logger.Fatal(\"ERROR: \" + err.Error())\n}\n\ncleverComURL, err := discovery.ExternalURL(\"clever.com\")\nif err != nil {\n    logger.Fatal(\"ERROR: \" + err.Error())\n}\n```\n\n### Implementation Details\n\nCurrently, `discovery-{go,node,python}` looks for environment variables with the following format:\n\n```\nSERVICE_{SERVICE_NAME}_{EXPOSE_NAME}_{PROTO,HOST,PORT}\n```\n\nThese environment variables are autogenerated [catapult](http://github.com/Clever/catapult) during app deployment.  Three env-vars are created for each app listed in the `dependencies` section of caller's launch yaml.\n\nFor example, if an app lists `district-authorizations` as a dependency, catapult will generate this env-vars triplet:\n\n```bash\nSERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PROTO = \"http\"\nSERVICE_DISTRICT_AUTHORIZATIONS_HTTP_HOST = \"district-authorizations.ops.clever.com\"\nSERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PORT = \"80\"\n```\n\nIt is also used to look for external urls with the format\n\n```\nEXTERNAL_URL_{URL_HOST}\n```\n\nFor example for `schools.clever.com` catapult will set:\n\n```bash\nEXTERNAL_URL_SCHOOLS_CLEVER_COM = \"https://schools.clever.com:443\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclever%2Fdiscovery-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclever%2Fdiscovery-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclever%2Fdiscovery-go/lists"}