stream is part of your API definition while sync/async is about
implementation.

You should decide whether to have "stream" according to whether you can
have more than one reply messages.
As you said, whether to use async or sync implementation is about your
resource limitations. If you have a server with a large number of pending
streams, you should consider async implementation.
If your client wants to listen to many servers for the update, you may want
to use async as well.

On Tue, Jun 13, 2017 at 11:32 AM, John Coffey <[email protected]> wrote:

> 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
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/7087cd4b-930f-4766-b040-68f73269dbf4%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/7087cd4b-930f-4766-b040-68f73269dbf4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAB1HKY6rCwH_6MNnZLonxCe84_0w1m2CHaL7ru_b6hxKi-WUxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to