liveBook · Manning

Stub

As explained in Designing AI Systems

A stub is a generated client-side proxy that represents remote operations as local callable methods.

A stub is generated client-side proxy code that represents remote operations as local callable methods. In a gRPC SDK, it connects a client to a service contract and hides serialization, transport, and response deserialization. section 4.5

A generated stub handles the client-side RPC path:

  • Expose one method for each operation declared in the Protocol Buffer service definition. section 4.5
  • Serialize Python request objects into binary Protocol Buffer messages. section 4.5
  • Send requests through the gRPC channel, optionally with routing metadata. section 4.5
  • Deserialize responses and return Python objects to the SDK client. section 4.5

Calling a generated session operation

The SDK builds a GetOrCreateSessionRequest, calls self._stub.GetOrCreateSession(request, metadata=self._metadata), then converts response.session into a Session object.

How Designing AI Systems covers it

How deep it goes
Explains generation, serialization, transport, deserialization, and SDK integration, but does not detail compiler configuration.
Examples
Demonstrates SessionClient setup and a get_or_create workflow for retrieving sessions and recording messages.
What it assumes
Assumes a Protocol Buffer service definition and generated Python files, while explaining how those artifacts support calls.
What you can do after
Apply generated stubs through a Python SDK to invoke remote operations and receive mapped domain objects.
How it connects
Connects stubs with gRPC, Protocol Buffers, RPC, service contracts, SDKs, and client-server architecture.

Also explained in

Compare how 14 books explain stub →

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.