CHAPTER 8Building RPC Applications with gRPC

In this chapter, you will learn to build network applications that use Remote Procedure Call (RPC) for communication. Although the standard library supports building such applications, we will do so using gRPC, an open-source universal RPC framework. We will start off with a quick background discussion of RPC frameworks, and we will end the chapter having learned to write completely testable gRPC applications. Along the way, you will also learn to use Protocol Buffers, an interface description language and a data interchange format that enables client-server communication over gRPC. Let's jump right in.

gRPC and Protocol Buffers

When you make a function call in your program, the function will usually be one that you have written yourself, or one provided by another package—from either the standard library or a third-party package. When you build the application, the binary contains that function's implementation inside it. Now imagine that you were able to make a function call, but instead of the function defined inside the application binary, the program calls the function defined in another service over the network. That is what Remote Procedure Call (RPC) is in a nutshell. Figure 8.1 illustrates a typical overview of how an RPC client and server communicates. It shows the request flow from the client to the server. The response flow, of course, happens in reverse and traverses through the same layers as the request.

Figure ...

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.