Closed Lukasa closed 4 years ago
Just to understand the ETA: with #222 being merged, when could we see a new version of swift-grpc and close this issue https://github.com/grpc/grpc-swift/issues/912?
@sweetbot there are still outstanding tasks to resolve this issue before we can tag a release of SwiftNIO HTTP/2. gRPC will then need to pick up the new version and any new changes that come with it. My hope is that we can tag a gRPC release by the end of the week.
In swift-nio-http2 today we have an unspoken hard requirement, which is that if you call
createStreamChannel
multiple times you must send the first write on each of those channels in the order you created them. This is becausecreateStreamChannel
allocates a stream ID immediately for each of those channels, but that allocation isn't meaningful until we try to write to the network. If you write out of order, the later streams will use the higher stream ID allocated to them, and will implicitly retire the lower IDs used by the earlier channels. When those earlier channels try to send, the core state machine will reject them for violating stream ID ordering.After discussing with @glbrntt we think this is made up of several changes:
HTTP2FrameConvertible
. This is a protocol that encapsulates creatingHTTP2Frame
s from a given object and vice-versa. We will have two conforming types:HTTP2Frame
(trivial) andHTTP2Frame.Payload
(straightforward, but not trivial). (#216)HTTP2FramePayloadConvertible
. This is the inverse of the previous protocol: creates a payload from the given object, or vice versa. (#216)HTTP2StreamChannel
generic over an outbound payload type conforming toHTTP2FrameConvertible
. This will become the inbound and outbound message type. This requires updates to the various inbound and outbound reading and writing functions. This should not require any interface changes on the interface between the multiplexer and the stream. The multiplexer will need to be updated to hold the new type (HTTP2StreamChannel<HTTP2Frame>
). (#218)struct
that provides the interfaceHTTP2StreamMultiplexer
expects fromHTTP2StreamChannel
, that holds the channel privately. This should be backed by anenum
, which we will use later to add a new case for the new channel type. RefactorHTTP2StreamMultiplexer
to use this type. (#215)HTTP2StreamChannel
to tolerate its streamID being optional, and nil on initialisation. This requires a new function onHTTP2StreamMultiplexer
to get the next stream ID, which is currently done increateStreamChannel
. (#217)createStreamChannel
function with a new initializer that no longer gets a stream ID. Plumb through this initializer to create new stream channels that useHTTP2Frame.Payload
instead ofHTTP2Frame
. Update theenum
created above for the new case. (#221)HTTP2FramePayloadConvertible
, and rename them. Create typealiases for both the old version (keeping its old name) and the new one that usesHTTP2FramePayload
. Deprecate the old typealias. (#222)HTTP2PipelineHelpers
function to use the new initializer. (#226, #227)