Repository navigation
Split-state AbstractStream; sending and receiving - #1656
Conversation
| this.writeQueue = handler.getWriteQueue(); | ||
| public NettyServerStream(Channel channel, TransportState state) { | ||
| super(new NettyWritableBufferAllocator(channel.alloc())); | ||
| this.state = checkNotNull(state, "transportState"); |
There was a problem hiding this comment.
nit: s/transportState/state/
There was a problem hiding this comment.
I purposefully was more verbose in the string, since "state must not be null" can be misunderstood as being useless (which state‽).
There was a problem hiding this comment.
ok with me. thought it was a leftover from a variable rename. I think either way is fine, as the resulting exception does contain a stacktrace, so it's easy to find out which state.
|
@ejona86 I like your changes. Much cleaner. Overall, looks good to me, to the extend that I understand all the implications 😄 |
| * | ||
| * @param <IdT> the type of the stream identifier | ||
| * Abstract base class for {@link ServerStream} implementations. Extending classes only need to | ||
| * implement transportState() and abstractServerStreamSink(). |
There was a problem hiding this comment.
nit: {@link #transportState}, {@link #abstractServerStreamSink}. I like the naming of abstractServerStreamSink btw ;-).
|
I've addressed @buchgr's comments. Now that we've done the 0.14 release, I think I'm going to try to push this through a bit more. |
|
@buchgr, from discussing with others you are going to be the "primary" reviewer, in case you want to look a little closer for any reason. @louiscryan and @nmittler, you may want to take a glance over this. |
| } | ||
|
|
||
| /** | ||
| * Only called from transport thread (except for private interactions with AbstractStream2). |
There was a problem hiding this comment.
nit: use {@code AbstractStream2} in any javadocs to help with the future rename?
|
@ejona86 I took a quick look ... |
|
@carl-mastrangelo, you may want to take a glance over this. |
| @@ -0,0 +1,261 @@ | |||
| /* | |||
| * Copyright 2014, Google Inc. All rights reserved. | |||
There was a problem hiding this comment.
Believe it or not, this started as copy of AbstractStream.java. The only reason it is a new file is to avoid updating client-side at the same time. I'd just assume leave the year alone.
Note to reviewers: You may want to start with NettyServerStream to help
give a grounding to understand the other changes.
Note also that I don't consider this to be an alternative to #1135. I feel
this PR is a stepping stone in order to do things like #1135. My main
concern during review is to avoid rabbit holing. I know there's many things
I could have done and that will become more obvious due to this PR.
But I really don't want to get too side-tracked on those things and instead
focus more on whether this PR allows us to discuss and implement those
other things easier.
I know there's places that could use more docs, but I didn't feel they
were likely very necessary during initial review. I'm happy to add more
docs if it seems like the changes are well accepted. Included in that is
porting AbstractStream's tests to AbstractStream2.
This introduces an AbstractStream2 that is intended to replace the
current AbstractStream. Only server-side is implemented in this commit
which is why AbstractStream remains. This is mostly a reorganization of
AbstractStream and children, but minor internal behavioral changes were
required which makes it appear more like a reimplementation.
A strong focus was on splitting state that is maintained on the
application's thread (with Stream) and state that is maintained by the
transport (and used for StreamListener). By splitting the state it makes
it much easier to verify thread-safety and to reason about interactions.
I consider this a stepping stone for making even more changes to
simplify the Stream implementations and do not think some of the changes
are yet at their logical conclusion. Some of the changes may also
immediately be replaced with something better. The focus was to improve
readability and comprehesibility to more easily make more interesting
changes.
The only thing really removed is some state checking during sending
which is already occurring in ServerCallImpl.