Hello,

I'm following up on my questions here 
<https://groups.google.com/g/grpc-io/c/5hFrAnj23lw?pli=1> with another, 
more specific question on the manual flow control example code 
<https://github.com/grpc/grpc-java/tree/master/examples/src/main/java/io/grpc/examples/manualflowcontrol>
 (any 
feedback on my recent questions appreciated as well).

My understanding of the example code is:
1. The client is sending the names to the server and respecting outbound 
flow control with this condition 
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlClient.java#L77>
 + 
using its ready handler.
2. The server disables auto flow control 
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlServer.java#L42>,
 
which means that it won't process an onNext message (from the client) until 
it calls request(1).
3. The server's ready handler then ensures the outbound direction (to 
client) has capacity 
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlServer.java#L60>
 before 
it "primes the pump" by calling request(1) (and it later only ever calls 
request(1) when there's outbound capacity). This use of manual flow control 
is providing the invariant that "if the server processes an onNext, we know 
there is capacity to send the ACK message to the client [without excess 
buffering]." If the server *didn't* drop into manual flow control mode, and 
simply processed onNext automatically when a message came in, it runs the 
risk of its outbound onReady to be false, and then it's stuck with a 
message that it can't ACK back to client safely (e.g. case where client 
sends many messages to server quickly, but client can't receive them as 
quickly).

If that's all correct, my question is around the manual flow control in the 
client code - the client drops into manual mode here 
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlClient.java#L57>.
 
Its onNext 
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/manualflowcontrol/ManualFlowControlClient.java#L93-L98>
 
is very simple - print the message, and then call request(1). Is it fair to 
say that the client's usage of manual flow control is simply 
re-implementing "normal" behavior? The server code is doing what it needs 
to do to make sure it's responding to the client 1 message at a time, so 
wouldn't the overall example be the same if the client didn't use manual 
flow control, and simply logged out the server message in its onNext?

Thanks again!

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/0696c6f9-e766-4d8f-a46e-f639b6b62dd1n%40googlegroups.com.

Reply via email to