https://github.com/clever/discovery-node
Programmatically find services (like discovery-go, but for node)
https://github.com/clever/discovery-node
Last synced: about 1 year ago
JSON representation
Programmatically find services (like discovery-go, but for node)
- Host: GitHub
- URL: https://github.com/clever/discovery-node
- Owner: Clever
- Created: 2015-09-16T23:47:09.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-02T16:28:24.000Z (over 1 year ago)
- Last Synced: 2025-03-17T16:53:17.265Z (over 1 year ago)
- Language: TypeScript
- Size: 147 KB
- Stars: 3
- Watchers: 62
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# discovery-node
This library programmatically finds endpoints for dependencies. Similar to [discovery-go](https://github.com/Clever/discovery-go) and [discovery-python](https://github.com/Clever/discovery-python).
See [Service Discovery](https://clever.atlassian.net/wiki/spaces/ENG/pages/116686857/Discovery) for more details.
## API
- disc = **discovery**(\, \)
- disc.**proto**() - returns the service protocol
- disc.**host**() - returns the hostname or ip
- disc.**port**() - returns the port
- disc.**host_port**() - returns (\:\)
- disc.**proto_host**() - returns (\://\)
- disc.**url**() - returns the url (\://\:\)
- external_url(\) - returns the external url to use
### Install and import
```bash
npm install --save clever-discovery
```
```node
import { discovery, external_url } from "clever-discovery"
```
### Examples
```node
disc_gearman = discovery("gearman-admin", "http")
try gearman_url = disc_gearman.url() catch err then cb(err)
disc_systemic = discovery("systemic", "thrift")
try systemic_host = disc_systemic.host() catch err then cb(err)
try systemic_port = disc_systemic.port() catch err then cb(err)
try clever_com_url = external_url("clever.com") catch err then cb(err)
```
To see what interfaces a Clever service exposes, check its launch yaml. You should see one or more exposes listed, and the `name` of the expose is used as the `interface` value in the discovery client.