clever-discovery
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

discovery-node

This library programmatically finds endpoints for dependencies. Similar to discovery-go and discovery-python.

See Service Discovery for more details.

API

  • disc = discovery(<service>, <interface>)
    • disc.proto() - returns the service protocol
    • disc.host() - returns the hostname or ip
    • disc.port() - returns the port
    • disc.host_port() - returns (<host>:<port>)
    • disc.proto_host() - returns (<proto>://<host>)
    • disc.url() - returns the url (<proto>://<host>:<port>)

Install and import

npm install --save clever-discovery
discovery = require "clever-discovery"

Examples

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)

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.

Dependents (140)

Package Sidebar

Install

npm i clever-discovery

Weekly Downloads

1,535

Version

0.0.9

License

ISC

Unpacked Size

13.8 kB

Total Files

12

Last publish

Collaborators

  • cleverdrone
  • clever