liveBook · Manning

gRPC

As explained in Go in Practice, Second Edition

gRPC is a high-performance remote procedure call framework and protocol for defining services and invoking them across networks.

gRPC is a remote procedure call approach for distributed systems and microservices. It defines service contracts with protocol buffers, generates messaging scaffolding, and lets clients invoke operations across networks instead of exchanging loosely defined REST payloads. section 11.5

Use gRPC when a formally defined, high-throughput service contract matters:

  • Serialize, parse, and transmit messages faster than JSON, with protocol buffers providing formal serialization across languages. section 11.5
  • Generate boilerplate for message handling and service scaffolding instead of building variable-input JSON processing with raw messages, interfaces, and reflection. section 11.5
  • Accept trade-offs: binary output is not readily human-readable, browser testing is harder, contracts are more complicated to build, and incompatible changes can break clients. section 11.5

A chat service

Define CommentRequest, CommentResponse, and ChatService in proto3; generate code with protoc; run a Python server on localhost:50051; then have a Go client dial it, send a timestamped “Hello World!” comment, and print the returned message length and previous-comment count. Streaming can be declared with an RPC returning a stream of CommentResponse values.

How Go in Practice, Second Edition covers it

How deep it goes
Moves from RPC rationale through protocol-buffer trade-offs to proto3 definitions, code generation, server setup, client calls, and streaming.
Examples
Uses a proto3 chat service, protoc generation, a Python server, a Go client, timestamps, and a streaming response declaration.
What it assumes
Assumes familiarity with networked APIs and REST while demonstrating RPC contracts, serialization, generated code, and client-server setup.
What you can do after
Build it from scratch by defining proto3 contracts, generating service code, registering a server, dialing it, and invoking RPCs.
How it connects
Connects remote procedure calls, protocol buffers, REST, JSON, microservices, HTTP APIs, code generation, and streaming.

Also explained in

Compare how 10 books explain gRPC →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Practice, Second Edition. The section links point to the parts of the book it draws on.