O'Reilly logo

TypeScript Microservices by Parth Ghiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subscribing to updates

Just like Eureka, we will constantly get the Consul registry, so whenever we need to communicate to another registry we won't need to make another registry call, as the registry is already cached at our end. Consul takes care of this by providing a feature called watch. Responses to a service will have an index number, which can be used for future requests to compare. They are nothing but a cursor to keep track of where we have left off. Let's add watchers to our application:

  1. Create a new watcher by adding the following code. Here, we have created a watcher on the service named data in Consul:
let watcher = consul.watch({  method: consul.health.service,  options: {    service: 'data',    passing: true  }});
  1. Next, we will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required