The client streaming API
Important note
In terms of the underlying protocol, the client streaming API uses Send Header
followed by multiple Send Message
and a Half-Close
from the client side, and Send Message
plus Send Trailer
from the server side.
With client streaming API endpoints, we can send zero or more requests and get one response. This is an important concept, especially for uploading data in real time. An example of this could be that we click on an edit button in our frontend, which triggers an edit session, and we post each edit being made in real time. Obviously, since we are not working with such fancy frontends, we are only going to focus on making the API compatible with this kind of feature.
To define a client streaming API, we simply need to write the stream
keyword in the parameter clause instead of return
. Previously, for our server streaming, we had the following:
rpc ListTasks(ListTasksRequest) returns (stream ListTasksResponse);
Now, we will have...