Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stub,examples: fix comments related to ServerCallStreamObserver.isReady() to clarify it applies to sending side readiness #8910

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sanjaypujare
Copy link
Contributor

fixed examples/manualflowcontrol/ManualFlowControlServer.java
fixed stub/ServerCallStreamObserver.java

to clarify the wording

@ejona86 as discussed.

…dy() to clarify it applies to sending side readiness
//
// Note: the onReadyHandler's invocation is serialized on the same thread pool as the incoming StreamObserver's
// onNext(), onError(), and onComplete() handlers. Blocking the onReadyHandler will prevent additional messages
// from being processed by the incoming StreamObserver. The onReadyHandler must return in a timely manner or
// from being processed by the sending StreamObserver. The onReadyHandler must return in a timely manner or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this. It was previously correct, and the change is incorrect. The inbound stream observer is the one with callbacks, and those are sharing the executor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think the main thing to note is "onReadyHandler's invocation is serialized on the same thread pool as the incoming StreamObserver's onNext(), onError(), and onComplete() handlers" and with that the "incoming" makes sense.

I was thinking that the isReady() call is on the sending side and hence the onReadyHandler is also on the sending side i.e. the callbacks are made from the sending side so if you block inside the callback you are blocking the sending side's processing.

Will revert ...

@@ -42,11 +42,11 @@ public static void main(String[] args) throws InterruptedException, IOException
serverCallStreamObserver.disableAutoRequest();

// Set up a back-pressure-aware consumer for the request stream. The onReadyHandler will be invoked
// when the consuming side has enough buffer space to receive more messages.
// when the sending side has enough buffer space to store more responses.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"consuming side" makes sense to talk about. But "sending side" is this side, so is strange. Maybe instead:

The onReadyHandler will be invoked when there is available buffer space to store more responses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back-pressure detection includes both local and remote buffer availability on the sending side, is that right? If the remote side (client in this case) has no buffer to receive responses it will cause back-pressure (thru TCP) and the sending side's buffer will fill up. And when that buffer is full, that is when isReady() will be false, IIUC.

Your suggested wording is concise and better so I will change to that.

@@ -98,7 +98,7 @@ public void disableAutoRequest() {


/**
* If {@code true}, indicates that the observer is capable of sending additional messages
* If {@code true}, indicates that the observer is capable of sending additional responses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh. Does this actually help anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I wanted to clarify this is because of the confusing and relative nature of words like "receiving" and "sending" in this context. For example, if you are a server you are receiving request messages on the wire through the requestObserver. But the requestObserver is "sending" these messages to the application through the onNext callback and I think some docs/comments do have that usage which is why I wanted to disambiguate here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants