Chapter 8. gRPC
RPC stands for Remote Procedure Call.
As the name suggests, the RPC API style focuses on interaction with APIs by invoking remote procedures (functions).
RPC APIs are characterized by intent-oriented interfaces, where an intent describes specific actions (operations), such as “CreateUser” or “GenerateReport.”
This approach lies on the opposite side of the spectrum compared to REST.
REST focuses on retrieval and modification of resources,1 like “User” and “Report,” using standardized HTTP methods like GET, POST, PUT, and DELETE.
gRPC2 may currently be the most widely adopted RPC implementation.3 It describes itself as a “high performance, open source universal RPC framework.” The project was created by Google, and in 2017, it was donated to the Cloud Native Computing Foundation, which hosts it at https://grpc.io.
After describing the overall goals of RPCs, this chapter introduces you to gRPC and its features. You’ll explore Protocol Buffers (the binary serialization format) and the HTTP/2 protocol (the transport mechanism used by gRPC; see “HTTP/2”). Using an implementation of an ECHO service, you’ll become familiar with the four RPC types supported by gRPC: unary, server streaming, client streaming, and bidirectional streaming. Next, using gRPC, you’ll enrich the WFS’s web feed from Chapter 7, with the content generated by a locally running LLM. The chapter ends with a discussion of gRPC security aspects, documentation, and trade-offs.