mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-30 05:28:45 +00:00
Implement direct stream (de)multiplexing in NIOHTTP2ChannelHandler (#380)
Motivation: Less expensive stream multiplexing. To implement direct stream multiplexing (with an incomplete public API) to break up delivery and allow testing. Modifications: * Factor out common inbound stream multiplexer functionality from `HTTP2StreamMultiplexer` into `CommonInboundStreamMultiplexer` (first commit). * Direct stream multiplexing is implemented as `InlineStreamMultiplexer`. It implements both the `HTTP2InboundStreamMultiplexer` and `HTTP2OutboundStreamMultiplexer` protocols. * We expose `NIOHTTP2Hander.StreamMultiplexer` as a `public` view over the new multiplexer to allow stream creation. * Adds various `propagate...` functions to relay signals such as read complete to the child channels held by the inline stream multiplexer. * Adds a stub for `HTTP2StreamDelegate` which will be completed in an upcoming PR. It will be responsible for surfacing stream open/close information. * Adds conveniences to `NIOHTTP2Handler` for setting up a handler using the inline multiplexer * Duplicate existing tests and modify to use the inline stream multiplexer where appropriate. `SimpleClientServerFramePayloadStreamTests.swift` and `HTTP2FramePayloadStreamMultiplexerTests.swift` were copied and modified Result: Default behavior should be unchanged at this time.
This commit is contained in:
1 parent
98170fdb0c
commit
befe813575
25 files changed
+3334
-281
No files matched your search
@@ -284,6 +284,11 @@ public enum NIOHTTP2Errors {
|
||||
return NoStreamIDAvailable(file: file, line: line)
|
||||
}
|
||||
|
||||
/// Creates a ``MissingMultiplexer`` error with appropriate source context.
|
||||
public static func missingMultiplexer(file: String = #fileID, line: UInt = #line) -> MissingMultiplexer {
|
||||
return MissingMultiplexer(file: file, line: line)
|
||||
}
|
||||
|
||||
/// Creates a ``StreamError`` error with appropriate source context.
|
||||
///
|
||||
/// - parameters:
|
||||
@@ -1641,6 +1646,26 @@ public enum NIOHTTP2Errors {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ``HTTP2ChannelHandler`` does not have a multiplexer but one has been accessed.
|
||||
public struct MissingMultiplexer: NIOHTTP2Error {
|
||||
private let file: String
|
||||
private let line: UInt
|
||||
|
||||
/// The location where the error was thrown.
|
||||
public var location: String {
|
||||
return _location(file: self.file, line: self.line)
|
||||
}
|
||||
|
||||
fileprivate init(file: String, line: UInt) {
|
||||
self.file = file
|
||||
self.line = line
|
||||
}
|
||||
|
||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user