swift-nio/Sources/NIOTLS
Franz Busch d836d6bef5
Add `AsyncChannel` based `ServerBootstrap.bind()` methods (#2403)
* Add `AsyncChannel` based `ServerBootstrap.bind()` methods

# Motivation
In my previous PR, we added a new async bridge from a NIO `Channel` to Swift Concurrency primitives in the from of the `NIOAsyncChannel`. This type alone is already helpful in bridging `Channel`s to Concurrency; however, it is hard to use since it requires to wrap the `Channel` at the right time otherwise we will drop reads. Furthermore, in the case of protocol negotiation this becomes even trickier since we need to wait until it finishes and then wrap the `Channel`.

# Modification
This PR introduces a few things:
1. New methods on the `ServerBootstrap` which allow the creation of `NIOAsyncChannel` based channels. This can be used in all cases where no protocol negotiation is involved.
2. A new protocol and type called `NIOProtocolNegotiationHandler` and `NIOProtocolNegotiationResult` which is used to identify channel handlers that are doing protocol negotiation.
3. New methods on the `ServerBootstrap` that are aware of protocol negotiation.

# Result
We can now easily and safely create new `AsyncChannel`s from the `ServerBootstrap`

* Code review

* Fix typo

* Fix up tests

* Stop finishing the writer when an error is caught

* Code review

* Fix up writer tests

* Introduce shared protocol negotiation handler state machine

* Correctly handle multi threaded event loops

* Adapt test to assert the channel was closed correctly.

* Code review
2023-04-26 07:17:07 -07:00
..
ApplicationProtocolNegotiationHandler.swift Add `AsyncChannel` based `ServerBootstrap.bind()` methods (#2403) 2023-04-26 07:17:07 -07:00
NIOTypedApplicationProtocolNegotiationHandler.swift Add `AsyncChannel` based `ServerBootstrap.bind()` methods (#2403) 2023-04-26 07:17:07 -07:00
ProtocolNegotiationHandlerStateMachine.swift Add `AsyncChannel` based `ServerBootstrap.bind()` methods (#2403) 2023-04-26 07:17:07 -07:00
SNIHandler.swift Drop Swift 5.5 (#2406) 2023-04-17 08:40:35 +01:00
TLSEvents.swift Replace `NIOSendable` with `Sendable` (#2291) 2022-10-13 15:56:27 +01:00