this is likely a very dumb question, but i am confused as to how to attach the new channel interfaces to the old ServerBootstrap childChannelInitializers.
this doesn’t compile:
.childChannelInitializer
{
(channel:any Channel) -> EventLoopFuture<Void> in
channel.pipeline.addHandler(NIOSSLServerHandler.init(context: authority.tls))
.flatMap
{
channel.configureAsyncHTTPServerPipeline
{
(connection:any Channel) in
connection.eventLoop.makeCompletedFuture
{
try NIOAsyncChannel<HTTPServerRequestPart, HTTPServerResponsePart>.init(
synchronouslyWrapping: connection,
configuration: .init())
}
}
http2ConnectionInitializer:
{
(connection:any Channel) in
connection.eventLoop.makeCompletedFuture
{
try NIOAsyncChannel<HTTP2Frame, HTTP2Frame>(
synchronouslyWrapping: connection,
configuration: .init())
}
}
http2InboundStreamInitializer:
{
(stream:any Channel) in
stream.eventLoop.makeCompletedFuture
{
try NIOAsyncChannel<
HTTP2Frame.FramePayload,
HTTP2Frame.FramePayload>.init(
synchronouslyWrapping: stream,
configuration: .init())
}
}
}
}
because the configureAsyncHTTPServerPipeline returns a
EventLoopFuture<
EventLoopFuture<
NIONegotiatedHTTPVersion<
NIOAsyncChannel<
HTTPServerRequestPart,
HTTPServerResponsePart>,
(
NIOAsyncChannel<HTTP2Frame, HTTP2Frame>,
NIOHTTP2Handler.AsyncStreamMultiplexer<
NIOAsyncChannel<
HTTP2Frame.FramePayload,
HTTP2Frame.FramePayload>>
)>>>
which is a magnificent type sculpture - truly a thing of beauty - but sadly incompatible with childChannelInitializer, which expects a humble EventLoopFuture<Void>.
your article suggests to instead add all the handlers, including the TLS handler, during the bind call. to which i must ask, what is the difference between the two childChannelInitializers?
does the one passed to bind override the one stored inside the ServerBootstrap? is there any reason to use childChannelInitializer on ServerBootstrap anymore?
another concurrent remark: i am getting Sendable warnings related to IOData:
conformance of 'IOData' to 'Sendable' is unavailable
conformance of 'IOData' to 'Sendable' has been explicitly marked unavailable here
this is because HTTPServerResponsePart is a union with IOData:
/// The components of a HTTP response from the view of a HTTP server.
public typealias HTTPServerResponsePart = HTTPPart<HTTPResponseHead, IOData>