Book Image

TypeScript Microservices

Book Image

TypeScript Microservices

Overview of this book

In the last few years or so, microservices have achieved the rock star status and right now are one of the most tangible solutions in enterprises to make quick, effective, and scalable applications. The apparent rise of Typescript and long evolution from ES5 to ES6 has seen lots of big companies move to ES6 stack. If you want to learn how to leverage the power of microservices to build robust architecture using reactive programming and Typescript in Node.js, then this book is for you. Typescript Microservices is an end-to-end guide that shows you the implementation of microservices from scratch; right from starting the project to hardening and securing your services. We will begin with a brief introduction to microservices before learning to break your monolith applications into microservices. From here, you will learn reactive programming patterns and how to build APIs for microservices. The next set of topics will take you through the microservice architecture with TypeScript and communication between services. Further, you will learn to test and deploy your TypeScript microservices using the latest tools and implement continuous integration. Finally, you will learn to secure and harden your microservice. By the end of the book, you will be able to build production-ready, scalable, and maintainable microservices using Node.js and Typescript.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Service discovery patterns


Discovery is the counterpart of service registry from the view of clients. Whenever a client wants to access a service, it must find details about the service, where it is located, and other contract information. This is typically done using two approaches, client-side discovery and server-side discovery. Service discovery can be briefly summarized as follows:

  • Microservices or consumers don't have any prior knowledge about the physical location of other services. They don't know when a service goes down or another node of the service is going up.
  • Services broadcast their existence and disappearance.
  • Services are able to other service instances based on other broadcasted metadata.
  • Instance failures are detected and any request to that failed node is prevented and is made invalid.
  • Service discovery is not a single point of failure.

In this section, we will both look at the patterns of service discovery and understand the pros and cons of each pattern.

Client-side discovery...