How containerd/ttrpc works
Project type and purpose
• This is a Go-based RPC library and toolchain (“ttrpc”) designed to generate and run lightweight RPC services in low-memory environments.
• It includes:
– Two protoc plugins (protoc-gen-go-ttrpc, protoc-gen-gogottrpc) for code generation
– A Go runtime library (client, server, channel, stream, interceptor, metadata, errors) implementing a custom framing protocol
– Example application and integration tests demonstrating usage
File structure
Top-level directories and roles:
• cmd/… — CLI tools that register with protoc to generate ttrpc code
• plugin/ — shared code for writing new code-gen plugins
• internal/ — low-level generated pb.go files for tests
• example/ — a sample client/server app using ttrpc
• integration/ — end-to-end streaming tests
• script/ — helpers (e.g., install-protobuf)
• proto/ — shared .proto definitions for status and requests
• root Go files (channel.go, client.go, server.go, etc.) implement the core library
Key configuration and build files:
• Makefile / Protobuild.toml — orchestrate build of .proto → .pb.go and .ttrpc.pb.go
• go.mod / go.sum — module dependencies
README for additional insights
• Purpose: reduce dependency on net/http, http2 and grpc package for smaller binaries
• Protocol spec in PROTOCOL.md defines framing, error handling, streaming
• Usage: plug into protoc (or Protobuild) to generate both client and server stubs
• Plugin registration hook (cmd/... → plugin/generator.go)
• Interceptor chain wrapping Channel.Invoke
• Framing protocol layer replacing HTTP/2 in grpc-go
• PROTOCOL.md reference near the transport layer