From f73f69faf7501b0bfea003910474a5016fbbf00a Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Wed, 9 Aug 2023 10:17:34 +0100 Subject: [PATCH] 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. --- Package.swift | 2 +- .../NIOTSAsyncBootstrapTests.swift | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Package.swift b/Package.swift index 8444173..805e20f 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,7 @@ let package = Package( .library(name: "NIOTransportServices", targets: ["NIOTransportServices"]), ], 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-docc-plugin", from: "1.0.0"), ], diff --git a/Tests/NIOTransportServicesTests/NIOTSAsyncBootstrapTests.swift b/Tests/NIOTransportServicesTests/NIOTSAsyncBootstrapTests.swift index d83b6da..fc4dd9e 100644 --- a/Tests/NIOTransportServicesTests/NIOTSAsyncBootstrapTests.swift +++ b/Tests/NIOTransportServicesTests/NIOTSAsyncBootstrapTests.swift @@ -249,7 +249,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { try await withThrowingTaskGroup(of: Void.self) { group in for try await negotiationResult in channel.inboundStream { group.addTask { - switch try await negotiationResult.get().waitForFinalResult() { + switch try await negotiationResult.getResult() { case .string(let channel): for try await value in channel.inboundStream { continuation.yield(.string(value)) @@ -269,7 +269,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { port: channel.channel.localAddress!.port!, proposedALPN: .string ) - switch try await stringNegotiationResult.get().waitForFinalResult() { + switch try await stringNegotiationResult.getResult() { case .string(let stringChannel): // This is the actual content try await stringChannel.outboundWriter.write("hello") @@ -283,7 +283,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { port: channel.channel.localAddress!.port!, proposedALPN: .byte ) - switch try await byteNegotiationResult.get().waitForFinalResult() { + switch try await byteNegotiationResult.getResult() { case .string: preconditionFailure() case .byte(let byteChannel): @@ -322,7 +322,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { try await withThrowingTaskGroup(of: Void.self) { group in for try await negotiationResult in channel.inboundStream { group.addTask { - switch try await negotiationResult.get().waitForFinalResult() { + switch try await negotiationResult.getResult() { case .string(let channel): for try await value in channel.inboundStream { continuation.yield(.string(value)) @@ -343,7 +343,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { proposedOuterALPN: .string, proposedInnerALPN: .string ) - switch try await stringStringNegotiationResult.get().waitForFinalResult() { + switch try await stringStringNegotiationResult.getResult() { case .string(let stringChannel): // This is the actual content try await stringChannel.outboundWriter.write("hello") @@ -358,7 +358,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { proposedOuterALPN: .byte, proposedInnerALPN: .string ) - switch try await byteStringNegotiationResult.get().waitForFinalResult() { + switch try await byteStringNegotiationResult.getResult() { case .string(let stringChannel): // This is the actual content try await stringChannel.outboundWriter.write("hello") @@ -373,7 +373,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { proposedOuterALPN: .byte, proposedInnerALPN: .byte ) - switch try await byteByteNegotiationResult.get().waitForFinalResult() { + switch try await byteByteNegotiationResult.getResult() { case .string: preconditionFailure() case .byte(let byteChannel): @@ -388,7 +388,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { proposedOuterALPN: .string, proposedInnerALPN: .byte ) - switch try await stringByteNegotiationResult.get().waitForFinalResult() { + switch try await stringByteNegotiationResult.getResult() { case .string: preconditionFailure() case .byte(let byteChannel): @@ -450,7 +450,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { try await withThrowingTaskGroup(of: Void.self) { group in for try await negotiationResult in channel.inboundStream { group.addTask { - switch try await negotiationResult.get().waitForFinalResult() { + switch try await negotiationResult.getResult() { case .string(let channel): for try await value in channel.inboundStream { continuation.yield(.string(value)) @@ -471,7 +471,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { proposedALPN: .unknown ) await XCTAssertThrowsError( - try await failedProtocolNegotiation.get().waitForFinalResult() + try await failedProtocolNegotiation.getResult() ) // Let's check that we can still open a new connection @@ -480,7 +480,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { port: channel.channel.localAddress!.port!, proposedALPN: .string ) - switch try await stringNegotiationResult.get().waitForFinalResult() { + switch try await stringNegotiationResult.getResult() { case .string(let stringChannel): // This is the actual content 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(MessageToByteHandler(LineDelimiterCoder())) try channel.pipeline.syncOperations.addHandler(TLSUserEventHandler(proposedALPN: proposedOuterALPN)) - let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler(eventLoop: channel.eventLoop) { alpnResult, channel in + let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler { alpnResult, channel in switch alpnResult { case .negotiated(let alpn): switch alpn { @@ -610,7 +610,7 @@ final class AsyncChannelBootstrapTests: XCTestCase { @discardableResult private func addTypedApplicationProtocolNegotiationHandler(to channel: Channel) throws -> NIOTypedApplicationProtocolNegotiationHandler { - let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler(eventLoop: channel.eventLoop) { alpnResult, channel in + let negotiationHandler = NIOTypedApplicationProtocolNegotiationHandler { alpnResult, channel in switch alpnResult { case .negotiated(let alpn): switch alpn {