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 specific service
- Handling errors
gRPC simply provides you to execute a server function within your local application via gRPC stubs which are responsible for marshalling request and send to server to execute it on the server side as well as unmarshalling response once the response received as shown in below.
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 contains gRPC stubs as go module dependencies in client side. gRPC also provides flexible configurations for client connection to make inter-service communication more reliable. Those configurations that allow us to retry operation based on the response status or error type we get from gRPC response. Now let’s take a look physical example to better understand how communication works, and how we can handle error cases to have better failover strategy.