From 380fe3318b5ab3cacee2912faf0cae699f7ee0e1 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 8 Apr 2024 17:56:02 +0300 Subject: [PATCH] 1.5.0 (#18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * swift-docc-plugin 1.3.0 * async-http-client 1.19.0 * replaced deprecated .createNew with the new .singleton * Adding _find capability. (#13) * docs * tabs * renames * added test for find method with body * docs added * findError added * tests renamed * added test for find method with generic type * docs * README updated * updated dependencies * docs updated * try Swift 5.7.1 * Update build-ubuntu.yml * Swift 5.7.3 * Revert "Swift 5.7.3" This reverts commit ab8f67a89f5b83ed20fe30a9965a3f2f58f6d2c1. * updated dependencies * Docs updated * Delete .github/workflows/CodeQL.yml * dependencies updated * fixed when update method didn’t use passed dateEncodingStrategy * noData error added * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * migrating to new HTTPClientRequest from HTTPClient.Request wip * … * migrating to new HTTPClientRequest from HTTPClient.Request wip * rename * tests updated * auth fixed * collect body bytes before returning response * param renamed to make keep backward compatibility with old methods * marking old find as deprecated * private * deprecated message * renames * moved deprecations * docs * docs * added Codable to CouchDBRepresentable protocol * added RowsResponse model * docs * Vapor tutorial updated * docs * docs and refactoring * docs and refactoring * Tutorials updated * docs * platforms list updated * minimum swift version 5.8 * workflow updated * Update build-ubuntu.yml * Update build-macos.yml * import NIOFoundationCompat to fix building on Ubuntu * using async-http-client from 1.21.0. Not calling http * Using HTTPClient.shared if eventLoopGroup not provided. No more calls httpClient.syncShutdown() if using shared singleton --------- Co-authored-by: Gregório Gevartosky Torrezan --- Package.resolved | 4 +- Package.swift | 2 +- .../CouchDBClient/CouchDB+Deprecated.swift | 16 ++-- Sources/CouchDBClient/CouchDBClient.swift | 80 ++++++++++++------- 4 files changed, 63 insertions(+), 39 deletions(-) diff --git a/Package.resolved b/Package.resolved index a2013f7..422111b 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swift-server/async-http-client.git", "state" : { - "revision" : "291438696abdd48d2a83b52465c176efbd94512b", - "version" : "1.20.1" + "revision" : "fb308ee72f3d4c082a507033f94afa7395963ef3", + "version" : "1.21.0" } }, { diff --git a/Package.swift b/Package.swift index 27c9a46..e57410c 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( .library(name: "CouchDBClient", targets: ["CouchDBClient"]), ], dependencies: [ - .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.0.0"), + .package(url: "https://github.com/swift-server/async-http-client", from: "1.21.0"), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0") ], targets: [ diff --git a/Sources/CouchDBClient/CouchDB+Deprecated.swift b/Sources/CouchDBClient/CouchDB+Deprecated.swift index 3ef03e5..fb253f3 100644 --- a/Sources/CouchDBClient/CouchDB+Deprecated.swift +++ b/Sources/CouchDBClient/CouchDB+Deprecated.swift @@ -64,12 +64,14 @@ extension CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -110,12 +112,14 @@ extension CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } diff --git a/Sources/CouchDBClient/CouchDBClient.swift b/Sources/CouchDBClient/CouchDBClient.swift index a9146e2..34039fd 100644 --- a/Sources/CouchDBClient/CouchDBClient.swift +++ b/Sources/CouchDBClient/CouchDBClient.swift @@ -166,12 +166,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -214,12 +216,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -253,12 +257,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -312,12 +318,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -426,12 +434,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -580,12 +590,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -661,12 +673,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -803,12 +817,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -915,12 +931,14 @@ public class CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } } @@ -1006,12 +1024,14 @@ internal extension CouchDBClient { if let eventLoopGroup = eventLoopGroup { httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) } else { - httpClient = HTTPClient(eventLoopGroupProvider: .singleton) + httpClient = HTTPClient.shared } defer { - DispatchQueue.main.async { - try? httpClient.syncShutdown() + if eventLoopGroup != nil { + DispatchQueue.main.async { + try? httpClient.syncShutdown() + } } }