So I naively started looking into adding this. I technically got it working by ignoring all of the threading/race conditions. :-)
However, in doing so, I see what you mean now; on the server-side, the server's method is given the responseObserver as an argument, so they can make calls on it (e.g. setOnReadyHandler) before the ServerCalls has started doing .request/etc. work.
But for the client-side, the client code is only given the requestObserver as a return argument, e.g. after ClientCalls has initiated the whole startCall/etc. workflow, so things are already in motion by the time the client might want to say "oh right, tell me when data is ready" or "disable auto flow control".
Does that sound right?
If so, it seems like a fundamental limitation of the "this looks like a method call" RPC convention, without something ugly like the client passing along with "configure request observer" function that ClientCalls could invoke before returning, e.g.:
requestObserver = stub.someBidiMethod(responseObserver, requestObserver -> { // call .setOnReadyHandler here });
...
Tangential question, but does Stream.request(numMessages) result in a wire call?
I had thought it would, in that the javadocs said "requests up given number of messages to be delivered", I had thought "requests" == "ask the server", e.g. the server would say "I can send one message, okay sent it, now wait for the client to ack back (via request(N)) that it's ready for more". (And vice versa on the client.)
So basically there would only ever be one message (or numMessages) in flight at a time.
However, AFAICT, calling request(numMessages) just ends in incrementing MessageDeframer.pendingDeliveries, e.g. the server-side could be actively sending more messages, and they'll sit in some buffers on the client-side, until MessageDeframer calls processBody to drain it.
Does that sound right?
Granted, having only one request/response message inflight at a time did seem less-than-ideal, but isn't some sort of "client calling back to the server"/vice versa what flow control is supposed to do?
(FWIW I did try to
RTFM. :-))
Thanks!
- Stephen