Client streaming
Client streaming is the opposite of server streaming. In client streaming RPCs, the client sends multiple messages to the server, which in turn sends back a single response. The response is typically returned after receiving all of the client messages, but that isn’t a hard requirement.
To get a better understanding of client streaming, let’s take a look at another example application. This time we’ll create a service that accepts a set of files. Once the client has sent all of its files, the service will return a zip file containing all of the files that were received.
Creating the protobuf file
As we did in the server streaming example, let’s start with the protobuf definition in proto/archiver.proto.
Protocol Buffer
syntax
=
"proto3"
;
package
practical
.
grpc.v1
;
service
Archiver
{
rpc
Zip
(
stream
ZipRequest
)
returns
(
ZipResponse
);
}
message
ZipRequest
{
string
file_name
=
1
;
bytes
contents
=
2
;
}
message
ZipResponse...