mirror of
https://github.com/apple/swift-nio
synced 2026-11-29 05:24:21 +00:00
* Add throwing version of `NIOAsyncSequenceProducer` # Motivation We recently introduced a `NIOAsyncSequenceProducer` to bridge a stream of elements from the NIO world into the async world. The introduced type was a non-throwing `AsyncSequence`. To support all use-cases we also need to offer a throwing variant of the type. # Modification - Introduce a new `NIOThrowingAsyncSequenceProducer` that is identical to the `NIOAsyncSequenceProducer` except that it has a `Failure` generic parameter and that the `next()` method is throwing. - Extract the `StateMachine` from both `AsyncSequenceProducer`s and unify them. - There is one modification in behaviour: `didTerminate` is now only called after `nil` or the error has been consumed from the sequence. # Result We now have a throwing variant of the `NIOAsyncSequenceProducer`. * Code review and fix CI * Remove duplicated code Co-authored-by: Cory Benfield <lukasa@apple.com>