mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Since nio 2.78, adding handlers to a pipeline requires the handlers to be sendable. That makes the [NIOAsyncTestingChannel.init(handlers➿)](https://swiftpackageindex.com/apple/swift-nio/2.78.0/documentation/nioembedded/nioasynctestingchannel/init(handlers➿)) function cumbersome, because you cannot create handlers and then call the function (unless your handlers are Sendable) even if you never use the handlers elsewhere. This PR adds a new initializer which takes a closure. The closure is run on-loop before the channel is registered. This means we can do: ```swift let channel = try await NIOAsyncTestingChannel { let handler = MyUnsendableHandler() try $0.pipeline.syncOperations.addHandler(handler) } ```