Adopt latest AsyncChannel SPI changes (#183)
# Motivation We had some breaking changes in the NIO AsyncChannel SPI which we have to adapt here. # Modification This PR updates to the latest AsyncChannel SPI # Result No more warnings and errors when building.
This commit is contained in:
parent
b4d9e61a6d
commit
f73f69faf7
|
|
@ -21,7 +21,7 @@ let package = Package(
|
||||||
.library(name: "NIOTransportServices", targets: ["NIOTransportServices"]),
|
.library(name: "NIOTransportServices", targets: ["NIOTransportServices"]),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/apple/swift-nio.git", from: "2.57.0"),
|
.package(url: "https://github.com/apple/swift-nio.git", from: "2.58.0"),
|
||||||
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
|
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
|
||||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
try await withThrowingTaskGroup(of: Void.self) { group in
|
try await withThrowingTaskGroup(of: Void.self) { group in
|
||||||
for try await negotiationResult in channel.inboundStream {
|
for try await negotiationResult in channel.inboundStream {
|
||||||
group.addTask {
|
group.addTask {
|
||||||
switch try await negotiationResult.get().waitForFinalResult() {
|
switch try await negotiationResult.getResult() {
|
||||||
case .string(let channel):
|
case .string(let channel):
|
||||||
for try await value in channel.inboundStream {
|
for try await value in channel.inboundStream {
|
||||||
continuation.yield(.string(value))
|
continuation.yield(.string(value))
|
||||||
|
|
@ -269,7 +269,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
port: channel.channel.localAddress!.port!,
|
port: channel.channel.localAddress!.port!,
|
||||||
proposedALPN: .string
|
proposedALPN: .string
|
||||||
)
|
)
|
||||||
switch try await stringNegotiationResult.get().waitForFinalResult() {
|
switch try await stringNegotiationResult.getResult() {
|
||||||
case .string(let stringChannel):
|
case .string(let stringChannel):
|
||||||
// This is the actual content
|
// This is the actual content
|
||||||
try await stringChannel.outboundWriter.write("hello")
|
try await stringChannel.outboundWriter.write("hello")
|
||||||
|
|
@ -283,7 +283,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
port: channel.channel.localAddress!.port!,
|
port: channel.channel.localAddress!.port!,
|
||||||
proposedALPN: .byte
|
proposedALPN: .byte
|
||||||
)
|
)
|
||||||
switch try await byteNegotiationResult.get().waitForFinalResult() {
|
switch try await byteNegotiationResult.getResult() {
|
||||||
case .string:
|
case .string:
|
||||||
preconditionFailure()
|
preconditionFailure()
|
||||||
case .byte(let byteChannel):
|
case .byte(let byteChannel):
|
||||||
|
|
@ -322,7 +322,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
try await withThrowingTaskGroup(of: Void.self) { group in
|
try await withThrowingTaskGroup(of: Void.self) { group in
|
||||||
for try await negotiationResult in channel.inboundStream {
|
for try await negotiationResult in channel.inboundStream {
|
||||||
group.addTask {
|
group.addTask {
|
||||||
switch try await negotiationResult.get().waitForFinalResult() {
|
switch try await negotiationResult.getResult() {
|
||||||
case .string(let channel):
|
case .string(let channel):
|
||||||
for try await value in channel.inboundStream {
|
for try await value in channel.inboundStream {
|
||||||
continuation.yield(.string(value))
|
continuation.yield(.string(value))
|
||||||
|
|
@ -343,7 +343,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
proposedOuterALPN: .string,
|
proposedOuterALPN: .string,
|
||||||
proposedInnerALPN: .string
|
proposedInnerALPN: .string
|
||||||
)
|
)
|
||||||
switch try await stringStringNegotiationResult.get().waitForFinalResult() {
|
switch try await stringStringNegotiationResult.getResult() {
|
||||||
case .string(let stringChannel):
|
case .string(let stringChannel):
|
||||||
// This is the actual content
|
// This is the actual content
|
||||||
try await stringChannel.outboundWriter.write("hello")
|
try await stringChannel.outboundWriter.write("hello")
|
||||||
|
|
@ -358,7 +358,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
proposedOuterALPN: .byte,
|
proposedOuterALPN: .byte,
|
||||||
proposedInnerALPN: .string
|
proposedInnerALPN: .string
|
||||||
)
|
)
|
||||||
switch try await byteStringNegotiationResult.get().waitForFinalResult() {
|
switch try await byteStringNegotiationResult.getResult() {
|
||||||
case .string(let stringChannel):
|
case .string(let stringChannel):
|
||||||
// This is the actual content
|
// This is the actual content
|
||||||
try await stringChannel.outboundWriter.write("hello")
|
try await stringChannel.outboundWriter.write("hello")
|
||||||
|
|
@ -373,7 +373,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
proposedOuterALPN: .byte,
|
proposedOuterALPN: .byte,
|
||||||
proposedInnerALPN: .byte
|
proposedInnerALPN: .byte
|
||||||
)
|
)
|
||||||
switch try await byteByteNegotiationResult.get().waitForFinalResult() {
|
switch try await byteByteNegotiationResult.getResult() {
|
||||||
case .string:
|
case .string:
|
||||||
preconditionFailure()
|
preconditionFailure()
|
||||||
case .byte(let byteChannel):
|
case .byte(let byteChannel):
|
||||||
|
|
@ -388,7 +388,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
proposedOuterALPN: .string,
|
proposedOuterALPN: .string,
|
||||||
proposedInnerALPN: .byte
|
proposedInnerALPN: .byte
|
||||||
)
|
)
|
||||||
switch try await stringByteNegotiationResult.get().waitForFinalResult() {
|
switch try await stringByteNegotiationResult.getResult() {
|
||||||
case .string:
|
case .string:
|
||||||
preconditionFailure()
|
preconditionFailure()
|
||||||
case .byte(let byteChannel):
|
case .byte(let byteChannel):
|
||||||
|
|
@ -450,7 +450,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
try await withThrowingTaskGroup(of: Void.self) { group in
|
try await withThrowingTaskGroup(of: Void.self) { group in
|
||||||
for try await negotiationResult in channel.inboundStream {
|
for try await negotiationResult in channel.inboundStream {
|
||||||
group.addTask {
|
group.addTask {
|
||||||
switch try await negotiationResult.get().waitForFinalResult() {
|
switch try await negotiationResult.getResult() {
|
||||||
case .string(let channel):
|
case .string(let channel):
|
||||||
for try await value in channel.inboundStream {
|
for try await value in channel.inboundStream {
|
||||||
continuation.yield(.string(value))
|
continuation.yield(.string(value))
|
||||||
|
|
@ -471,7 +471,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
proposedALPN: .unknown
|
proposedALPN: .unknown
|
||||||
)
|
)
|
||||||
await XCTAssertThrowsError(
|
await XCTAssertThrowsError(
|
||||||
try await failedProtocolNegotiation.get().waitForFinalResult()
|
try await failedProtocolNegotiation.getResult()
|
||||||
)
|
)
|
||||||
|
|
||||||
// Let's check that we can still open a new connection
|
// Let's check that we can still open a new connection
|
||||||
|
|
@ -480,7 +480,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
port: channel.channel.localAddress!.port!,
|
port: channel.channel.localAddress!.port!,
|
||||||
proposedALPN: .string
|
proposedALPN: .string
|
||||||
)
|
)
|
||||||
switch try await stringNegotiationResult.get().waitForFinalResult() {
|
switch try await stringNegotiationResult.getResult() {
|
||||||
case .string(let stringChannel):
|
case .string(let stringChannel):
|
||||||
// This is the actual content
|
// This is the actual content
|
||||||
try await stringChannel.outboundWriter.write("hello")
|
try await stringChannel.outboundWriter.write("hello")
|
||||||
|
|
@ -579,7 +579,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
try channel.pipeline.syncOperations.addHandler(ByteToMessageHandler(LineDelimiterCoder()))
|
try channel.pipeline.syncOperations.addHandler(ByteToMessageHandler(LineDelimiterCoder()))
|
||||||
try channel.pipeline.syncOperations.addHandler(MessageToByteHandler(LineDelimiterCoder()))
|
try channel.pipeline.syncOperations.addHandler(MessageToByteHandler(LineDelimiterCoder()))
|
||||||
try channel.pipeline.syncOperations.addHandler(TLSUserEventHandler(proposedALPN: proposedOuterALPN))
|
try channel.pipeline.syncOperations.addHandler(TLSUserEventHandler(proposedALPN: proposedOuterALPN))
|
||||||
let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult>(eventLoop: channel.eventLoop) { alpnResult, channel in
|
let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult> { alpnResult, channel in
|
||||||
switch alpnResult {
|
switch alpnResult {
|
||||||
case .negotiated(let alpn):
|
case .negotiated(let alpn):
|
||||||
switch alpn {
|
switch alpn {
|
||||||
|
|
@ -610,7 +610,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
private func addTypedApplicationProtocolNegotiationHandler(to channel: Channel) throws -> NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult> {
|
private func addTypedApplicationProtocolNegotiationHandler(to channel: Channel) throws -> NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult> {
|
||||||
let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult>(eventLoop: channel.eventLoop) { alpnResult, channel in
|
let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler<NegotiationResult> { alpnResult, channel in
|
||||||
switch alpnResult {
|
switch alpnResult {
|
||||||
case .negotiated(let alpn):
|
case .negotiated(let alpn):
|
||||||
switch alpn {
|
switch alpn {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue