liveBook · Manning

Protoc

As explained in Designing AI Systems

The Protocol Buffer compiler is a code-generation tool that transforms Protocol Buffer service and message definitions into language-specific source code.

protoc turns a Protocol Buffer service definition into executable, language-specific code. For a Python gRPC client, it generates message classes and a service stub, converting a declarative API contract into callable client infrastructure. section 4.5

A typical generated Python output contains:

  • sessions_pb2.py, containing classes for declared messages such as request and response types. section 4.5
  • sessions_pb2_grpc.py, containing a service stub with one method for each declared RPC. section 4.5
  • The stub serializes requests, sends binary data through the gRPC channel, deserializes responses, and exposes the exchange as a method call. section 4.5

Using generated code in an SDK

A SessionClient creates SessionServiceStub(self._channel), builds a generated GetOrCreateSessionRequest, invokes the RPC, and converts the generated response into a domain Session object. Regenerate the stubs whenever the proto definition changes, preferably through a pre-commit hook or CI step. section 4.5

How Designing AI Systems covers it

How deep it goes
Explains generated messages, stubs, serialization, transport, and regeneration practice without detailing compiler internals.
Examples
Uses generated session messages, SessionServiceStub, and a get-or-create workflow as concrete implementation examples.
What it assumes
Assumes a proto service definition and gRPC client structure; teaches generated message classes and stubs from that contract.
What you can do after
Apply it via the Protocol Buffer compiler to generate Python message classes and gRPC stubs from a proto service definition.
How it connects
Connects Protocol Buffers, gRPC, RPC methods, serialization, deserialization, and SDK service clients.

Also explained in

Compare how 5 books explain protoc →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.