I have a general question about using the Asynchronous APIs. I basically want to write a client that listens for updates as they are received by the server.
On the server side, there seem to be multiple ways to define this in the proto file, and I am not sure which one I should use. Looking at the examples greeters applications, it looks like one of these streams the replies while the other does not. This is a bit confusing as the introduction of the 'stream' keyword does not prevent async communications. Could someone explain the difference.
Previously, I developed a grpc service using Stream responses using the Synchronous API, and I could basically have my client wait in a separate thread for the individual responses to get received. In this case I had do do quite a bit of thread management on the server and the client which (if I am not mistaken) I may be able to simplify if I use a truly asynchronous API.
Below you can see the 2 types of rpc definitions in the proto files I mentioned above.
// The greeting service definition.
service MultiGreeter {
// Sends multiple greetings
rpc sayHello (HelloRequest) returns (stream HelloReply) {}
}
This is the streaming version
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
Non Streaming version