🔌 gRPC Beginner

What are the four types of gRPC service methods?

Answer

gRPC defines four communication patterns: (1) Unary RPC — the client sends one request and gets one response, like a function call: rpc GetUser(Request) returns (Response); (2) Server Streaming RPC — the client sends one request and gets a stream of responses: rpc ListUsers(Request) returns (stream Response); (3) Client Streaming RPC — the client sends a stream of requests and gets one response: rpc UploadFile(stream Chunk) returns (Response); (4) Bidirectional Streaming RPC — both client and server send streams of messages independently: rpc Chat(stream Message) returns (stream Message). The appropriate type depends on the use case: unary for simple lookups, server streaming for large result sets, client streaming for uploads, bidirectional for real-time interactive communication.