From the course: Node.js: Microservices

What's your goal for this chapter? - Node.js Tutorial

From the course: Node.js: Microservices

What's your goal for this chapter?

- [Host] By now we have two applications, the shopper frontend and the catalog service. We know that the catalog service listens on a random part and it can even run on a completely different host or in some container or even in the cloud. The problem is now that the shopper application cannot know where to find the catalog service, neither its IP Address nor its port is known. We would need something like a phone book that contains a list of services and the locations and the so-called service registry is exactly that. We would need something like a phone book that contains a list of all services, and their locations and the so-called service registry is exactly that. Let's see how this works. The service registry is nothing but a service itself. It just listens on a known port. There are other ways to make even this dynamic but from my experience, abstraction needs to end somewhere where things just get too complicated. Now, when a service starts up, it does a rest call to the service registry and registers itself with its name, its IP and its port. The service registry now stores this information. Next, when the shop app now wants to call the catalog service it first asks the service registry for its location. The service registry ideally now returns the location of the catalog service. Now, when the shopper app wants to call the catalog service it'll first ask the service registry for its location. The service registry hopefully then returns this location and with that information we can finally make the call to the catalog service. This is the bare minimum functionality. In this chapter, we will also make sure that services can unregister themselves on shutdown and also will be removed if this suddenly disappear without notice. This is called a timeout. So are you ready? Let's get started.

Contents