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

Implement outbound flow control #6

Closed
ejona86 opened this issue Jan 7, 2015 · 11 comments
Closed

Implement outbound flow control #6

ejona86 opened this issue Jan 7, 2015 · 11 comments
Assignees

Comments

@ejona86
Copy link
Member

ejona86 commented Jan 7, 2015

Should be token-based a la reactive streams. Although it also seems that maybe we will only ever have at most 1 token passed to the application.

Currently we provide no method of pushback to the application and buffer infinitely as the application sends.

@nmittler
Copy link
Member

nmittler commented Feb 9, 2015

@ejona86 @louiscryan I'm looking at the right place add this...

I suppose I can just add a request(numMessages) method to Call.Listener and then have Call.sendPayload throw if no message has been requested. Thoughts?

@ejona86
Copy link
Member Author

ejona86 commented Feb 9, 2015

That requires StreamObserver to buffer, unless we expose flow control to the applications. Would it be better to be advisory and code is allowed to ignore it if it doesn't care about flow control? Or does this encourage us to adopt full reactive-streams for StreamObserver and require applications to abide by flow control?

@nmittler
Copy link
Member

nmittler commented Feb 9, 2015

I was thinking that the stub layer would block until notified since we don't expose flow control at the stub layer. Is that not the behavior we had discussed in the past?

@ejona86
Copy link
Member Author

ejona86 commented Feb 9, 2015

I still feel like we can't block when the application calls StreamObserver.onValue. If it can block, then what is the point of going through the agony of using an async interface? If it can block, I suggest we just trash it altogether and tell people to use the blocking interface.

@nmittler
Copy link
Member

nmittler commented Feb 9, 2015

Ah right, good point. So I guess we should expose outbound flow control for async clients?

@ejona86
Copy link
Member Author

ejona86 commented Feb 9, 2015

@louiscryan What are your ideas for outbound flow control?

@nmittler
Copy link
Member

Discussed offline. Here's the idea...

Basically we just extend Call.Listener to have the reactivestreams-style request method.

interface Call.Listener {
    void onHeaders(...);
    void onPayload(...);
    void onClose(...);
    void onReady(int numMessages);
}

For now I think the method should be called onReady rather than request. First, request is more of a command which seems out of place in a listener interface. Second, I don't think we'll want to initially be as rigid as the reactivestreams API and fail if the user tries to send more data than has been request. Instead we'll let the user opt-in to outbound flow control, similar to stubby. This will allow the async stub to simply send data immediately without requiring any additional buffering.

I originally considered that onReady would have no arguments, however if we tell the listener the number of messages that it may send, this gives us some flexibility if we find that requesting one message at a time causes performance hiccups.

WDYT?

@nmittler
Copy link
Member

@louiscryan @ejona86 any thoughts before I start hacking? :)

@ejona86
Copy link
Member Author

ejona86 commented Feb 12, 2015

@nmittler, SGTM.

@JakeWharton
Copy link
Member

Request is a command in reactive streams hence its lack of "on". It's the
onStart or onNext callbacks issuing a command for data back upwards to the
source.
On Feb 12, 2015 10:36 AM, "Nathan Mittler" notifications@github.com wrote:

Discussed offline. Here's the idea...

Basically we just extend Call.Listener to have the reactivestreams-style
request method.

interface Call.Listener {
void onHeaders(...);
void onPayload(...);
void onClose(...);
void onReady(int numMessages);
}

For now I think the method should be called onReady rather than request.
First, request is more of a command which seems out of place in a
listener interface. Second, I don't think we'll want to initially be as
rigid as the reactivestreams API and fail if the user tries to send more
data than has been request. Instead we'll let the user opt-in to outbound
flow control, similar to stubby. This will allow the async stub to simply
send data immediately without requiring any additional buffering.

I originally considered that onReady would have no arguments, however if
we tell the listener the number of messages that it may send, this gives us
some flexibility if we find that requesting one message at a time causes
performance hiccups.

WDYT?


Reply to this email directly or view it on GitHub
#6 (comment).

@nmittler
Copy link
Member

nmittler commented May 4, 2015

Fixed by #348

@nmittler nmittler closed this as completed May 4, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants