2
votes

I would like to make client-side streaming blocking. The definition of that protocol can look like this:

rpc RecordRoute(stream Point) returns (RouteSummary) {}

As it's said in the documentation, for certain types of streaming call, it's only possible to use async stub:

a non-blocking/asynchronous stub that makes non-blocking calls to the server, where the response is returned asynchronously. You can make certain types of streaming call only using the asynchronous stub.

Then how can I make that call blocking/synchronous? Is it possible?

1

1 Answers

2
votes

Blocking stub can only be used for RPCs that client sends only a single request. For client streaming calls, you can only use async stub. The generated code for blocking stub does not contain the RPC method for client-streaming or bidi-streaming methods.

If you want to avoid excessive buffering due to async requests, you can use the CallStreamObServer API to do manual flow control. With some external synchronizations such as a CountDownLatch, the async API can behave synchronously. See how gRPC's manual flow control example works.