CHAPTER 10Production-Ready gRPC Applications
In this chapter, you will start by learning how to implement TLS-enabled secure gRPC applications. Then you will study techniques to implement health checks, handle runtime errors, and cancel processing in your server applications. After that, you will learn about techniques to improve the robustness of your client applications, such as configuring time-outs for various operations and handling transient failures. In the final section, you will learn how connections between clients and servers are internally managed by the gRPC library. Let's dive in!
Securing Communication with TLS
The client and server applications that we have written so far communicate over an insecure channel—this is the setupGrpcCommunication
(
)
function that we have been using in our clients to set up communication with a server:
func setupGrpcConnection(addr string) (*grpc.ClientConn, error) {
return grpc.DialContext(
context.Background(),
addr,
grpc.WithInsecure(),
grpc.WithBlock(),
)
}
The grpc.WithInsecure() DialOption
explicitly states that the client must communicate with the server over an insecure channel. Of course, this only works because our server applications were not configured to communicate over one. You will recall that we used Transport Layer Security (TLS) to secure the communication between HTTP client and server applications in Chapter 7, “Production-Ready HTTP Servers.” We can use the same technique to set up a secure a communication ...
Get Practical Go now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.