Skip to content

Instantly share code, notes, and snippets.

@cjus
Last active February 19, 2018 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjus/f302dc8882d31f87f580f801e88aeb0d to your computer and use it in GitHub Desktop.
Save cjus/f302dc8882d31f87f580f801e88aeb0d to your computer and use it in GitHub Desktop.
Hydra getServicePresence example
{
"hydra": {
"serviceName": "caller",
"serviceDescription": "",
"serviceIP": "",
"servicePort": 0,
"serviceType": "",
"redis": {
"url": "redis://localhost:6379/15"
}
}
}
const express = require('express');
const app = express();
const hydra = require('hydra');
const config = require('./config.json');

app.get('/', (req, res) => res.send('Hello World!'));
app.listen(3000, () => console.log('Example app listening on port 3000!'));

hydra.init(config)
  .then(() => {
    console.log('hydra initiated');
    return hydra.getServicePresence('hydra-router');
  })
  .then((service) => {
    console.log(service);
  })
  .catch((error) => {
    console.log(error)
  });
Array(1) [Object]
index.js:15
length:1
__proto__:Array(0) [, …]
0:Object {serviceName: "hydra-router", serviceDescription: "Service Router", version: "1.6.0", …}
  hostName:"AdministorsMBP2.fios-router.home"
  instanceID:"46bb1d0037264eb0898adde39cdd257e"
  ip:"192.168.1.221"
  port:1552
  processID:10750
  serviceDescription:"Service Router"
  serviceName:"hydra-router"
  updatedOn:"2018-02-19T03:55:52.114Z"
  updatedOnTS:1519012552114
  version:"1.6.0"
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment