mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
# Motivation
Over the past months, we have been working on new async bridges to make using NIO's `Channel` from Swift Concurrency possible. Since this work was far reaching we have opted to land all of it as SPI. Now the time has come and we feel confident enough to make the SPI official API. This comes after testing the new APIs in various scenarios such as HTTP 1&2, HTTP upgrades, protocol negotiation and in benchmarks.
# Modification
This PR removes the SPI from the `NIOAsyncChannel`, the bootstrap methods, protocol negotiation and HTTP upgrade.
# Result
Everyone can use the our new APIs🚀
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2023 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@testable import NIOCore
|
|
import XCTest
|
|
|
|
final class AsyncChannelOutboundWriterTests: XCTestCase {
|
|
func testTestingWriter() async throws {
|
|
let (writer, sink) = NIOAsyncChannelOutboundWriter<Int>.makeTestingWriter()
|
|
|
|
try await withThrowingTaskGroup(of: [Int].self) { group in
|
|
group.addTask {
|
|
var elements = [Int]()
|
|
for try await element in sink {
|
|
elements.append(element)
|
|
}
|
|
return elements
|
|
}
|
|
|
|
for element in 0...10 {
|
|
try await writer.write(element)
|
|
}
|
|
writer.finish()
|
|
|
|
let result = try await group.next()
|
|
XCTAssertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
}
|
|
}
|
|
}
|