From 11631fbae85daed16268004c9ef7b2b2f2eac766 Mon Sep 17 00:00:00 2001 From: Dianna Ma Date: Thu, 16 Jan 2025 00:52:47 +0000 Subject: [PATCH] upgrade to SwiftNIO 2.78 --- Package.resolved | 14 +++++----- Package.swift | 26 ++++++----------- .../Connections/Mongo.ConnectorFactory.swift | 28 +++++++++++-------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Package.resolved b/Package.resolved index 432acbf..833c6ba 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "daceeee59031d65a8c33cfb323a21ded2a125f3bdc49c26d3e67bcbc4f71d180", + "originHash" : "2a316d3f318f7c8b6ff89b547e013115e2f4b4235e2e139d5b3828f9c599b8c7", "pins" : [ { "identity" : "swift-atomics", @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tayloraswift/swift-bson", "state" : { - "revision" : "0fa7c4a61c509c78bcdc239f0185af188d9bc7da", - "version" : "0.9.0" + "revision" : "0d7c9735b726f931a67da00b836e8fd383f43cb3", + "version" : "1.0.0" } }, { @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tayloraswift/swift-grammar", "state" : { - "revision" : "4b47a153732e0b094ef7dd95d891b37b7ae37a69", - "version" : "0.4.1" + "revision" : "0dac977b50bf677b2c3adabd7d5586a7b6e09b17", + "version" : "0.5.0" } }, { @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio", "state" : { - "revision" : "dca6594f65308c761a9c409e09fbf35f48d50d34", - "version" : "2.77.0" + "revision" : "ba72f31e11275fc5bf060c966cf6c1f36842a291", + "version" : "2.79.0" } }, { diff --git a/Package.swift b/Package.swift index 515ab5b..97d2b18 100644 --- a/Package.swift +++ b/Package.swift @@ -14,23 +14,15 @@ let package:Package = .init(name: "swift-mongodb", .library(name: "UnixTime_Atomics", targets: ["UnixTime_Atomics"]), ], dependencies: [ - .package(url: "https://github.com/tayloraswift/swift-bson", - from: "0.9.0"), - .package(url: "https://github.com/tayloraswift/swift-grammar", - from: "0.4.0"), - .package(url: "https://github.com/tayloraswift/swift-hash", - from: "0.7.0"), - .package(url: "https://github.com/tayloraswift/swift-unixtime", - from: "0.1.5"), - - .package(url: "https://github.com/apple/swift-atomics", .upToNextMinor( - from: "1.2.0")), - .package(url: "https://github.com/apple/swift-collections", .upToNextMinor( - from: "1.1.0")), - - .package(url: "https://github.com/apple/swift-nio", "2.75.0" ..< "2.78.0"), - .package(url: "https://github.com/apple/swift-nio-ssl", - from: "2.28.0"), + .package(url: "https://github.com/tayloraswift/swift-bson", from: "1.0.0"), + .package(url: "https://github.com/tayloraswift/swift-grammar", from: "0.4.0"), + .package(url: "https://github.com/tayloraswift/swift-hash", from: "0.7.0"), + .package(url: "https://github.com/tayloraswift/swift-unixtime", from: "0.1.5"), + + .package(url: "https://github.com/apple/swift-atomics", from: "1.2.0"), + .package(url: "https://github.com/apple/swift-collections", from: "1.1.0"), + .package(url: "https://github.com/apple/swift-nio", from: "2.79.0"), + .package(url: "https://github.com/apple/swift-nio-ssl", from: "2.28.0"), ], targets: [ .target(name: "BSON_OrderedCollections", diff --git a/Sources/MongoDriver/Connections/Mongo.ConnectorFactory.swift b/Sources/MongoDriver/Connections/Mongo.ConnectorFactory.swift index 6987ba2..00f7242 100644 --- a/Sources/MongoDriver/Connections/Mongo.ConnectorFactory.swift +++ b/Sources/MongoDriver/Connections/Mongo.ConnectorFactory.swift @@ -54,20 +54,24 @@ extension Mongo.ConnectorFactory { (channel:any Channel) in - let parser:Mongo.WireMessageParser = .init() - let router:Mongo.WireMessageRouter = .init() - - guard case .enabled = self.tls - else - { - return channel.pipeline.addHandlers(parser, router) - } do { - let tls:NIOSSLClientHandler = try .init(context: .init( - configuration: .clientDefault), - serverHostname: host.name) - return channel.pipeline.addHandlers(tls, parser, router) + let parser:Mongo.WireMessageParser = .init() + let router:Mongo.WireMessageRouter = .init() + + switch self.tls + { + case .enabled: + let tls:NIOSSLClientHandler = try .init(context: .init( + configuration: .clientDefault), + serverHostname: host.name) + try channel.pipeline.syncOperations.addHandlers(tls, parser, router) + + case .disabled: + try channel.pipeline.syncOperations.addHandlers(parser, router) + } + + return channel.eventLoop.makeSucceededFuture(()) } catch let error {