gRPC: From service definition to wire format
4 days ago
- #gRPC
- #Protocol Buffers
- #HTTP/2
- gRPC is built on HTTP/2 and uses Protocol Buffers for payload encoding.
- Contract-first approach in gRPC enforces API structure upfront using .proto files.
- gRPC supports four streaming models: Unary, Server streaming, Client streaming, and Bidirectional streaming.
- Metadata in gRPC allows sending key-value pairs for cross-cutting concerns like authentication and tracing.
- gRPC URLs are automatically generated from .proto definitions in the format /{Package}.{Service}/{Method}.
- gRPC messages use length-prefixed framing with a 5-byte header indicating compression and message length.
- Status and errors in gRPC are communicated via trailers, including rich error models for detailed feedback.
- gRPC supports compression to reduce payload size, with negotiation and per-message compression flags.
- gRPC can run over alternative transports like Unix Domain Sockets and Named Pipes.
- gRPC-Web adapts gRPC for browser use by encoding trailers in the data stream and supporting base64 encoding.