5 Inter-service Communication
This chapter covers
- Understanding the internals of gRPC client-server connection strategies
- How to depend on a client module to access specific service
- Tips and tricks for client configuration of a particular service
- Handling errors
In the previous chapter, we implemented a gRPC service for Order Service. In this chapter, we will implement a gRPC client for that service to show how underlying communication works in Microservice Architecture.
Figure 5.1 Order Service uses Payment Service gRPC stub
In the previous chapters, we already saw how to generate Go source codes from proto files, this time, we will learn how to use those repositories that contain gRPC stubs as go module dependencies on the client side. gRPC also provides flexible configurations for client connection to make inter-service communication more reliable. Those configurations allow us to retry operations based on the response status or error type we get from the gRPC response. Now let’s take a look physical example to understand better how communication works and how we can handle error cases to have a better failover strategy.