At the moment, gRPC service definitions can only have a single parameter even if it’s a streaming service which makes challenging to represent the “initial” request. For instance, consider a chat app in which a user can join a chat room.
In this case, the domain can be modelled as follows.
message JoinRoomRequest {
required string room = 1;
}
message ChatMessage {
required string content = 2;
}
A consumer of the chat app would send a join request and start a bi-directional stream of messages, so the service can be described in this way.
service SimpleChat {
rpc joinChatRoom (JoinRoomRequest, stream ChatMessage) returns (stream ChatMessage);
}
However, in gRPC the above syntax is not valid. The only way to represent the described chat service is
service SimpleChat {
rpc joinChatRoom (stream ChatMessage) returns (stream ChatMessage);
}
What is the reason behind this decision, and how a similar domain can be modelled in gRPC?