Reputation: 31
I see the following 4 types of RPC
in grpc
document:
- rpc SayHello(HelloRequest) returns (HelloResponse) {...}
- rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse) {...}
- rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse) {...}
- rpc BidiHello(stream HelloRequest) returns (stream HelloResponse) {...}
which means both the request and response can be single one or a sequence of message. Does the streaming request means that one can pack args of multiple invocation in the stream, implementing batch remote procedure call?
And, I'm very confused about the scenario where a stream of response is needed. What's the scenario of streaming response?
Upvotes: 2
Views: 2925
Reputation: 336
There are 4 types of RPCs:
Unary: Client sends a single request to the server, and server sends a single response
Server streaming: Client sends a single message to the server. Server responds with an ordered sequence of messages. Client reads from the stream until there are no more messages.
Client streaming: Client sends an ordered sequence of message to the server. Server reads the messages from the client and sends a response.
Bidirectional streaming: Both client and server send ordered sequences of messages to each other. The client and server streams are independent of each other.
Take a look at https://grpc.io/docs/guides/concepts/ for more info.
Upvotes: 4