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
Allow payload-based stream channels to be created. #221
Conversation
Hmm allocations have increased for |
ca8d1b4
to
59f9846
Compare
) | ||
self.streams[streamID] = channel | ||
channel.configure(initializer: self.inboundStreamStateInitializer, userPromise: nil) | ||
let channel: MultiplexerAbstractChannel |
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.
Can we arrange for MultiplexerAbstractChannel
to paper over this distinction? I think we can do it if we make the enum
for inboundStreamStateInitializer
something we pass to the MultiplexerAbstractChannel
and have it end up choosing which base channel to construct.
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.
Yeah, that's sensible. Done.
59f9846
to
616776d
Compare
@@ -25,21 +25,42 @@ import NIO | |||
/// The implementation of `Equatable` & `Hashable` on this type reinforces that requirement. | |||
struct MultiplexerAbstractChannel { | |||
private var baseChannel: BaseChannel | |||
private var inboundStreamStateInitializer: InboundStreamStateInitializer | |||
|
|||
private init(baseChannel: BaseChannel, inboundStreamStateInitializer: InboundStreamStateInitializer) { |
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.
Hmm, this isn't quite what I wanted either. I wanted to pass the initializer to the relevant functions. This forces us to store the inbound stream state initializer on all streams, which is mostly extra work for us. Any reason not to just pass it to configureInboundStream
?
We don't need to store this function: we just need to have it in the init
to know what channel to create. That's totally sufficient.
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.
Gotcha.
Motivation: To lift the requirement that stream creation order must match the order of the first write on those channels we added a payload-based stream channel. We need a way for users to create these channels and initialze these channels when they are inbound. Modifications: - Adds a `createStreamChannel` using a stream initialzer without a stream ID - Adds a new multiplexer `init` where the inbound stream initialzer does not use stream IDs - Adds an additional 'configure' to MultiplexerAbstractChannel - Replaces the `init` in `MultiplexerAbstractChannel` with two `static func`s: we can't switch on an optional stream ID since inbound streams always have a stream ID; we need to be be able to explicitly support choosing the type of channel we want. - Minor refactoring in `HTTP2StreamChannel` to avoid duplication between the `configure` functions Result: - The multiplexer can create payload based streams manually and when a new stream is inbound.
616776d
to
30e4d8d
Compare
Motivation: As part of the work for apple#214 we need new codecs which transform `HTTP2Frame.FramePayload` to and from the appropriate request and response parts. Modifications: - Add `HTTP2FramePayloadToHTTP1ClientCodec` - Add `HTTP2FramePayloadToHTTP1ServerCodec` - Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to use payloads instead of frames. - Add relevant test helpers. - Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated: doing so without warnings depends on apple#221. Result: - We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP client and server request and response types.
Motivation: As part of the work for apple#214 we need new codecs which transform `HTTP2Frame.FramePayload` to and from the appropriate request and response parts. Modifications: - Add `HTTP2FramePayloadToHTTP1ClientCodec` - Add `HTTP2FramePayloadToHTTP1ServerCodec` - Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to use payloads instead of frames. - Add relevant test helpers. - Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated: doing so without warnings depends on apple#221. Result: - We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP client and server request and response types.
Motivation: As part of the work for apple#214 we need new codecs which transform `HTTP2Frame.FramePayload` to and from the appropriate request and response parts. Modifications: - Add `HTTP2FramePayloadToHTTP1ClientCodec` - Add `HTTP2FramePayloadToHTTP1ServerCodec` - Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to use payloads instead of frames. - Add relevant test helpers. - Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated: doing so without warnings depends on apple#221. Result: - We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP client and server request and response types.
Motivation: As part of the work for apple#214 we need new codecs which transform `HTTP2Frame.FramePayload` to and from the appropriate request and response parts. Modifications: - Add `HTTP2FramePayloadToHTTP1ClientCodec` - Add `HTTP2FramePayloadToHTTP1ServerCodec` - Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to use payloads instead of frames. - Add relevant test helpers. - Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated: doing so without warnings depends on apple#221. Result: - We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP client and server request and response types.
Motivation: As part of the work for #214 we need new codecs which transform `HTTP2Frame.FramePayload` to and from the appropriate request and response parts. Modifications: - Add `HTTP2FramePayloadToHTTP1ClientCodec` - Add `HTTP2FramePayloadToHTTP1ServerCodec` - Duplicate the HTTP2ToHTTP1CodecTests and update the relevant parts to use payloads instead of frames. - Add relevant test helpers. - Note: the HTTP2 to HTTP1 (frame based) codecs haven't been deprecated: doing so without warnings depends on #221. Result: - We can transform `HTTP2Frame.FramePayload` types to the relevant HTTP client and server request and response types.
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.
Nice, LGTM.
Motivation:
To lift the requirement that stream creation order must match the order
of the first write on those channels we added a payload-based stream
channel. We need a way for users to create these channels and initialze
these channels when they are inbound.
Modifications:
createStreamChannel
using a stream initialzer without astream ID
init
where the inbound stream initialzer doesnot use stream IDs
init
inMultiplexerAbstractChannel
with twostatic func
s:we can't switch on an optional stream ID since inbound streams always
have a stream ID; we need to be be able to explicitly support choosing
the type of channel we want.
HTTP2StreamChannel
to avoid duplication between theconfigure
functionsResult:
new stream is inbound.