Skip to content

core,netty: split stream state on client-side; AbstractStream2 - #2140

Merged
ejona86 merged 1 commit into
grpc:masterfrom
ejona86:split-abstractclientstream
Oct 3, 2016
Merged

ejona86 merged 1 commit into
grpc:masterfrom
ejona86:split-abstractclientstream

Conversation

@ejona86

@ejona86 ejona86 commented Aug 8, 2016

Copy link
Copy Markdown
Member

OkHttp will need to be migrated in a future commit.

This is a continuation of what already was done for server-side (#1656). Although
AbstractClientStream2 looks like new code, it is a reorganization of existing code
(although heavily reworked).

* Requests up to the given number of messages from the call to be delivered. This should end up
* triggering {@link TransportState#requestMessagesFromDeframer(int)} on the transport thread.
*/
void request(int numMessages);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: seems a bit strange to call request on something called a Sink

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The other class is called TransportState. Perhaps a better name for this interface would be ApplicationState?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Implementations of this interface don't generally hold interesting state. The application state is held by Abstract{Client,}Stream2.

The reason for this interface is to simplify the naming issues we were having and make it more obvious what calls what.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So then doesn't the same comment apply to TransportState? Perhaps both should be renamed to be more consistent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't really follow. Rename Abstract{Client,}Stream2 to ApplicationState? Rename TransportState to... ???Sink? Rename both? There's three classes/interfaces involved and I don't understand what pair would gain what advantage.

I don't see the lack of consistency here, because no class is a true inverse of another. I can agree that TransportState is a bit of a weak name, but it gets the point across pretty well and I'm not aware of a better name.

At some point we could introduce Sinks to TransportState. I didn't because it seemed to add complexity without actually simplifying anything, because the various methods are pretty intertwined (especially w.r.t. error handling, since the transport has to be notified).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No, I'm not suggesting that you rename the stream, itself. I'm suggesting that Sink/TransportState are two views of the stream, each performs ~half the work of the stream, and that they should have consistent names to make this more obvious. Names like ApplicationView and TransportView would make this clear in my mind.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm suggesting that Sink/TransportState are two views of the stream

But... it's not. Sink holds no state. Sink is only to make it obvious how the abstract class interacts with the subclass, and that those method have no need to interact with the rest of the stream state.

Names like ApplicationView and TransportView would make this clear in my mind.

I can't see any way I would use "View". View would seem to imply that the state is shared. That's exactly the opposite of what I want to portray.

If I called something ApplicationState it would be AbstractClientStream2. But that seems a much poorer name than its current name (even assuming that it was tweaked as necessary to ClientStreamApplicationState).

@buchgr

buchgr commented Sep 9, 2016 •

Copy link
Copy Markdown
Contributor

LGTM. I like your tests :).

@ejona86

ejona86 commented Sep 9, 2016 •

Copy link
Copy Markdown
Member Author

Would anyone like more time to review?

I expect there is still the variable name discussion that Nathan brought up. Is there anything else outstanding?

I like your tests :).

... what about them?

@buchgr

buchgr commented Sep 9, 2016

Copy link
Copy Markdown
Contributor

... what about them?

don't be scared :). I think there is an elegance to AbstractStream2Test.

@carl-mastrangelo

Copy link
Copy Markdown
Contributor

I will

@carl-mastrangelo

Copy link
Copy Markdown
Contributor

Derp, that button is too close.

super(maxMessageSize);
}

protected abstract void http2ProcessingFailed(Status status, Metadata trailers);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a javadoc to abstract methods?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants