Service Discovery

Both Service and Consumer mode applications can discover other services. But keep in mind that Consumer mode applications can't themselves be discoverable. Only registered services can be discoverable.

Services are discovered using thefindService()method. The findService() method accepts a service name and returns a promise which will resolve to a service information object or a rejected promise if the service can't be found.

  .then((service) => {
  .catch((err) => {
    console.log('catch err', err);

The service object returned might look like this:

  "serviceName": "imageprocessor",
  "processID": 25246,
  "registeredOn": "2016-03-26T18:26:31.334Z",
  "ip": "",
  "port": 9001,
  "type": "image:processing"

An application can then use theipandportinformation to call APIs on the imageprocessor service.

results matching ""

    No results matching ""