diff --git a/README.md b/README.md
index c619f770b7..aec720fe95 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@
-
+
diff --git a/Sources/Vapor/Cache/Application+Cache.swift b/Sources/Vapor/Cache/Application+Cache.swift
index 3d31b70c4c..7a960ba077 100644
--- a/Sources/Vapor/Cache/Application+Cache.swift
+++ b/Sources/Vapor/Cache/Application+Cache.swift
@@ -21,7 +21,7 @@ extension Application {
public struct Provider: Sendable {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -46,7 +46,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ makeCache: @Sendable @escaping (Application) -> (Cache)) {
+ @preconcurrency public func use(_ makeCache: @Sendable @escaping (Application) -> (Cache)) {
self.storage.makeCache.withLockedValue { $0 = .init(factory: makeCache) }
}
diff --git a/Sources/Vapor/Client/Application+Clients.swift b/Sources/Vapor/Client/Application+Clients.swift
index 82df6f59aa..e277b71a20 100644
--- a/Sources/Vapor/Client/Application+Clients.swift
+++ b/Sources/Vapor/Client/Application+Clients.swift
@@ -16,7 +16,7 @@ extension Application {
public struct Provider {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -43,7 +43,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ makeClient: @Sendable @escaping (Application) -> (Client)) {
+ @preconcurrency public func use(_ makeClient: @Sendable @escaping (Application) -> (Client)) {
self.storage.makeClient.withLockedValue { $0 = .init(factory: makeClient) }
}
diff --git a/Sources/Vapor/HTTP/BasicResponder.swift b/Sources/Vapor/HTTP/BasicResponder.swift
index d044669850..410ac232af 100644
--- a/Sources/Vapor/HTTP/BasicResponder.swift
+++ b/Sources/Vapor/HTTP/BasicResponder.swift
@@ -14,7 +14,7 @@ public struct BasicResponder: Responder {
///
/// - parameters:
/// - closure: Responder closure.
- public init(
+ @preconcurrency public init(
closure: @Sendable @escaping (Request) throws -> EventLoopFuture
) {
self.closure = closure
diff --git a/Sources/Vapor/HTTP/Server/HTTPServerUpgradeHandler.swift b/Sources/Vapor/HTTP/Server/HTTPServerUpgradeHandler.swift
index 2bf4f1b213..13f047ded7 100644
--- a/Sources/Vapor/HTTP/Server/HTTPServerUpgradeHandler.swift
+++ b/Sources/Vapor/HTTP/Server/HTTPServerUpgradeHandler.swift
@@ -138,7 +138,7 @@ public struct WebSocketUpgrader: Upgrader, Sendable {
var shouldUpgrade: (@Sendable () -> EventLoopFuture)
var onUpgrade: @Sendable (WebSocket) -> ()
- public init(maxFrameSize: WebSocketMaxFrameSize, shouldUpgrade: @escaping (@Sendable () -> EventLoopFuture), onUpgrade: @Sendable @escaping (WebSocket) -> ()) {
+ @preconcurrency public init(maxFrameSize: WebSocketMaxFrameSize, shouldUpgrade: @escaping (@Sendable () -> EventLoopFuture), onUpgrade: @Sendable @escaping (WebSocket) -> ()) {
self.maxFrameSize = maxFrameSize
self.shouldUpgrade = shouldUpgrade
self.onUpgrade = onUpgrade
diff --git a/Sources/Vapor/Middleware/ErrorMiddleware.swift b/Sources/Vapor/Middleware/ErrorMiddleware.swift
index f1f8b2cb91..2aab147430 100644
--- a/Sources/Vapor/Middleware/ErrorMiddleware.swift
+++ b/Sources/Vapor/Middleware/ErrorMiddleware.swift
@@ -68,7 +68,7 @@ public final class ErrorMiddleware: Middleware {
///
/// - parameters:
/// - closure: Error-handling closure. Converts `Error` to `Response`.
- public init(_ closure: @Sendable @escaping (Request, Error) -> (Response)) {
+ @preconcurrency public init(_ closure: @Sendable @escaping (Request, Error) -> (Response)) {
self.closure = closure
}
diff --git a/Sources/Vapor/Passwords/Application+Passwords.swift b/Sources/Vapor/Passwords/Application+Passwords.swift
index 38bf20d5d6..99c9a53b70 100644
--- a/Sources/Vapor/Passwords/Application+Passwords.swift
+++ b/Sources/Vapor/Passwords/Application+Passwords.swift
@@ -9,7 +9,7 @@ extension Application {
public struct Provider: Sendable {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -24,7 +24,7 @@ extension Application {
provider.run(self.application)
}
- public func use(
+ @preconcurrency public func use(
_ makeVerifier: @Sendable @escaping (Application) -> (PasswordHasher)
) {
self.storage.makeVerifier.withLockedValue { $0 = .init(factory: makeVerifier) }
diff --git a/Sources/Vapor/Request/Request+Body.swift b/Sources/Vapor/Request/Request+Body.swift
index 1dce10598f..5d7c857549 100644
--- a/Sources/Vapor/Request/Request+Body.swift
+++ b/Sources/Vapor/Request/Request+Body.swift
@@ -23,7 +23,7 @@ extension Request {
}
}
- public func drain(_ handler: @Sendable @escaping (BodyStreamResult) -> EventLoopFuture) {
+ @preconcurrency public func drain(_ handler: @Sendable @escaping (BodyStreamResult) -> EventLoopFuture) {
switch self.request.bodyStorage {
case .stream(let stream):
stream.read { (result, promise) in
diff --git a/Sources/Vapor/Responder/Application+Responder.swift b/Sources/Vapor/Responder/Application+Responder.swift
index 725ba3b1df..d38e7e8372 100644
--- a/Sources/Vapor/Responder/Application+Responder.swift
+++ b/Sources/Vapor/Responder/Application+Responder.swift
@@ -16,7 +16,7 @@ extension Application {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -56,7 +56,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ factory: @Sendable @escaping (Application) -> (Vapor.Responder)) {
+ @preconcurrency public func use(_ factory: @Sendable @escaping (Application) -> (Vapor.Responder)) {
self.storage.factory.withLockedValue { $0 = .init(factory: factory) }
}
diff --git a/Sources/Vapor/Routing/Request+WebSocket.swift b/Sources/Vapor/Routing/Request+WebSocket.swift
index 6476dd3215..0c0402fbc4 100644
--- a/Sources/Vapor/Routing/Request+WebSocket.swift
+++ b/Sources/Vapor/Routing/Request+WebSocket.swift
@@ -3,7 +3,7 @@ import WebSocketKit
import NIOHTTP1
extension Request {
- public func webSocket(
+ @preconcurrency public func webSocket(
maxFrameSize: WebSocketMaxFrameSize = .`default`,
shouldUpgrade: @escaping (@Sendable (Request) -> EventLoopFuture) = {
$0.eventLoop.makeSucceededFuture([:])
diff --git a/Sources/Vapor/Server/Application+Servers.swift b/Sources/Vapor/Server/Application+Servers.swift
index 88af203757..56e237a0f7 100644
--- a/Sources/Vapor/Server/Application+Servers.swift
+++ b/Sources/Vapor/Server/Application+Servers.swift
@@ -16,7 +16,7 @@ extension Application {
public struct Provider {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -47,7 +47,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ makeServer: @Sendable @escaping (Application) -> (Server)) {
+ @preconcurrency public func use(_ makeServer: @Sendable @escaping (Application) -> (Server)) {
self.storage.makeServer.withLockedValue { $0 = .init(factory: makeServer) }
}
diff --git a/Sources/Vapor/Sessions/Application+Sessions.swift b/Sources/Vapor/Sessions/Application+Sessions.swift
index 34aa36179b..87ff1f12ac 100644
--- a/Sources/Vapor/Sessions/Application+Sessions.swift
+++ b/Sources/Vapor/Sessions/Application+Sessions.swift
@@ -15,7 +15,7 @@ extension Application {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -71,7 +71,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ makeDriver: @Sendable @escaping (Application) -> (SessionDriver)) {
+ @preconcurrency public func use(_ makeDriver: @Sendable @escaping (Application) -> (SessionDriver)) {
self.storage.makeDriver.withLockedValue { $0 = .init(factory: makeDriver) }
}
diff --git a/Sources/Vapor/Sessions/SessionsConfiguration.swift b/Sources/Vapor/Sessions/SessionsConfiguration.swift
index e6c32a6c86..86868d9ded 100644
--- a/Sources/Vapor/Sessions/SessionsConfiguration.swift
+++ b/Sources/Vapor/Sessions/SessionsConfiguration.swift
@@ -17,7 +17,7 @@ public struct SessionsConfiguration: Sendable {
/// - parameters:
/// - cookieName: Name of HTTP cookie, used as a key for the cookie value.
/// - cookieFactory: Creates a new `HTTPCookieValue` for the supplied value `String`.
- public init(cookieName: String, cookieFactory: @Sendable @escaping (SessionID) -> HTTPCookies.Value) {
+ @preconcurrency public init(cookieName: String, cookieFactory: @Sendable @escaping (SessionID) -> HTTPCookies.Value) {
self.cookieName = cookieName
self.cookieFactory = cookieFactory
}
diff --git a/Sources/Vapor/Utilities/FileIO.swift b/Sources/Vapor/Utilities/FileIO.swift
index 70eee659d4..c3cae017a1 100644
--- a/Sources/Vapor/Utilities/FileIO.swift
+++ b/Sources/Vapor/Utilities/FileIO.swift
@@ -86,7 +86,7 @@ public struct FileIO: Sendable {
/// - chunkSize: Maximum size for the file data chunks.
/// - onRead: Closure to be called sequentially for each file data chunk.
/// - returns: `Future` that will complete when the file read is finished.
- public func readFile(
+ @preconcurrency public func readFile(
at path: String,
chunkSize: Int = NonBlockingFileIO.defaultChunkSize,
onRead: @Sendable @escaping (ByteBuffer) -> EventLoopFuture
@@ -122,7 +122,7 @@ public struct FileIO: Sendable {
/// - mediaType: HTTPMediaType, if not specified, will be created from file extension.
/// - onCompleted: Closure to be run on completion of stream.
/// - returns: A `200 OK` response containing the file stream and appropriate headers.
- public func streamFile(
+ @preconcurrency public func streamFile(
at path: String,
chunkSize: Int = NonBlockingFileIO.defaultChunkSize,
mediaType: HTTPMediaType? = nil,
diff --git a/Sources/Vapor/Utilities/Thread.swift b/Sources/Vapor/Utilities/Thread.swift
index d97009fed4..50735883d0 100644
--- a/Sources/Vapor/Utilities/Thread.swift
+++ b/Sources/Vapor/Utilities/Thread.swift
@@ -2,7 +2,7 @@ import Foundation
extension Thread {
/// Convenience wrapper around `Thread.detachNewThread`.
- public static func async(_ work: @Sendable @escaping () -> ()) {
+ @preconcurrency public static func async(_ work: @Sendable @escaping () -> ()) {
Thread.detachNewThread {
work()
}
diff --git a/Sources/Vapor/Validation/Validations.swift b/Sources/Vapor/Validation/Validations.swift
index e7952cc76e..5019dcce36 100644
--- a/Sources/Vapor/Validation/Validations.swift
+++ b/Sources/Vapor/Validation/Validations.swift
@@ -36,7 +36,7 @@ public struct Validations: Sendable {
self.storage.append(.init(nested: key, required: required, keyed: validations, customFailureDescription: customFailureDescription))
}
- public mutating func add(
+ @preconcurrency public mutating func add(
each key: ValidationKey,
required: Bool = true,
customFailureDescription: String? = nil,
diff --git a/Sources/Vapor/Validation/Validator.swift b/Sources/Vapor/Validation/Validator.swift
index 9abcf303fe..99cdce92da 100644
--- a/Sources/Vapor/Validation/Validator.swift
+++ b/Sources/Vapor/Validation/Validator.swift
@@ -1,6 +1,6 @@
public struct Validator: Sendable {
public let validate: @Sendable (_ data: T) -> ValidatorResult
- public init(validate: @Sendable @escaping (_ data: T) -> ValidatorResult) {
+ @preconcurrency public init(validate: @Sendable @escaping (_ data: T) -> ValidatorResult) {
self.validate = validate
}
}
diff --git a/Sources/Vapor/View/Application+Views.swift b/Sources/Vapor/View/Application+Views.swift
index 1e555e3118..e06f33516b 100644
--- a/Sources/Vapor/View/Application+Views.swift
+++ b/Sources/Vapor/View/Application+Views.swift
@@ -22,7 +22,7 @@ extension Application {
let run: @Sendable (Application) -> ()
- public init(_ run: @Sendable @escaping (Application) -> ()) {
+ @preconcurrency public init(_ run: @Sendable @escaping (Application) -> ()) {
self.run = run
}
}
@@ -56,7 +56,7 @@ extension Application {
provider.run(self.application)
}
- public func use(_ makeRenderer: @Sendable @escaping (Application) -> (ViewRenderer)) {
+ @preconcurrency public func use(_ makeRenderer: @Sendable @escaping (Application) -> (ViewRenderer)) {
self.storage.makeRenderer.withLockedValue { $0 = .init(factory: makeRenderer) }
}
diff --git a/Sources/XCTVapor/XCTApplication.swift b/Sources/XCTVapor/XCTApplication.swift
index 7b09e843e7..d4497db61b 100644
--- a/Sources/XCTVapor/XCTApplication.swift
+++ b/Sources/XCTVapor/XCTApplication.swift
@@ -48,7 +48,7 @@ extension Application {
try app.server.start(address: .hostname(self.hostname, port: self.port))
defer { app.server.shutdown() }
- let client = HTTPClient(eventLoopGroupProvider: .createNew)
+ let client = HTTPClient(eventLoopGroup: NIOSingletons.posixEventLoopGroup)
defer { try! client.syncShutdown() }
var path = request.url.path
path = path.hasPrefix("/") ? path : "/\(path)"