-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,11 +42,11 @@ public StreamObserver<HelloRequest> sayHelloStreaming(final StreamObserver<Hello | |
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. | ||
// | ||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Will revert ... |
||
// else message processing throughput will suffer. | ||
class OnReadyHandler implements Runnable { | ||
// Guard against spurious onReady() calls caused by a race between onNext() and onReady(). If the transport | ||
|
@@ -61,7 +61,7 @@ public void run() { | |
wasReady = true; | ||
logger.info("READY"); | ||
// Signal the request sender to send one message. This happens when isReady() turns true, signaling that | ||
// the receive buffer has enough free space to receive more messages. Calling request() serves to prime | ||
// the send buffer has enough free space to send more responses. Calling request() serves to prime | ||
// the message pump. | ||
serverCallStreamObserver.request(1); | ||
} | ||
|
@@ -95,8 +95,8 @@ public void onNext(HelloRequest request) { | |
// cycling through the loop of onNext() -> request(1)...onNext() -> request(1)... until the client runs | ||
// out of messages and ends the loop (via onCompleted()). | ||
// | ||
// If request() was called here with the argument of more than 1, the server might runs out of receive | ||
// buffer space, and isReady() will turn false. When the receive buffer has sufficiently drained, | ||
// If request() was called here with the argument of more than 1, the server might run out of response | ||
// buffer space, and isReady() will turn false. When the response buffer has sufficiently drained, | ||
// isReady() will turn true, and the serverCallStreamObserver's onReadyHandler will be called to restart | ||
// the message pump. | ||
serverCallStreamObserver.request(1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meh. Does this actually help anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
* without requiring excessive buffering internally. This value is just a suggestion and the | ||
* application is free to ignore it, however doing so may result in excessive buffering within the | ||
* observer. | ||
|
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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.