diff --git a/Sources/APNSExample/Program.swift b/Sources/APNSExample/Program.swift index b7bce40..838253d 100644 --- a/Sources/APNSExample/Program.swift +++ b/Sources/APNSExample/Program.swift @@ -50,7 +50,7 @@ struct Main { ), environment: .development ), - eventLoopGroupProvider: .createNew, + eventLoopGroupProvider: .shared(MultiThreadedEventLoopGroup.singleton), responseDecoder: JSONDecoder(), requestEncoder: JSONEncoder() ) diff --git a/Sources/APNSTestServer/APNSTestServer.swift b/Sources/APNSTestServer/APNSTestServer.swift index e4b8ad5..a7dc5e6 100644 --- a/Sources/APNSTestServer/APNSTestServer.swift +++ b/Sources/APNSTestServer/APNSTestServer.swift @@ -96,8 +96,12 @@ public final class APNSTestServer: @unchecked Sendable { .serverChannelOption(ChannelOptions.backlog, value: 256) .serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1) .childChannelInitializer { channel in - channel.pipeline.configureHTTPServerPipeline().flatMap { - channel.pipeline.addHandler(APNSRequestHandler(server: self)) + do { + try channel.pipeline.syncOperations.configureHTTPServerPipeline() + try channel.pipeline.syncOperations.addHandler(APNSRequestHandler(server: self)) + return channel.eventLoop.makeSucceededVoidFuture() + } catch { + return channel.eventLoop.makeFailedFuture(error) } } diff --git a/Tests/APNSTests/APNSClientIntegrationTests.swift b/Tests/APNSTests/APNSClientIntegrationTests.swift index b65677b..6b292c0 100644 --- a/Tests/APNSTests/APNSClientIntegrationTests.swift +++ b/Tests/APNSTests/APNSClientIntegrationTests.swift @@ -16,6 +16,7 @@ import APNS import APNSTestServer import Crypto +import NIOPosix import XCTest final class APNSClientIntegrationTests: XCTestCase { @@ -40,7 +41,7 @@ final class APNSClientIntegrationTests: XCTestCase { ), environment: .custom(url: "http://127.0.0.1", port: serverPort) ), - eventLoopGroupProvider: .createNew, + eventLoopGroupProvider: .shared(MultiThreadedEventLoopGroup.singleton), responseDecoder: JSONDecoder(), requestEncoder: JSONEncoder() ) diff --git a/Tests/APNSTests/Broadcast/APNSBroadcastClientTests.swift b/Tests/APNSTests/Broadcast/APNSBroadcastClientTests.swift index 3bb5033..e352390 100644 --- a/Tests/APNSTests/Broadcast/APNSBroadcastClientTests.swift +++ b/Tests/APNSTests/Broadcast/APNSBroadcastClientTests.swift @@ -16,6 +16,7 @@ import APNS import APNSTestServer import Crypto +import NIOPosix import XCTest final class APNSBroadcastClientTests: XCTestCase { @@ -39,7 +40,7 @@ final class APNSBroadcastClientTests: XCTestCase { ), environment: .custom(url: "http://127.0.0.1", port: serverPort), bundleID: "com.example.testapp", - eventLoopGroupProvider: .createNew, + eventLoopGroupProvider: .shared(MultiThreadedEventLoopGroup.singleton), responseDecoder: JSONDecoder(), requestEncoder: JSONEncoder() )