Skip to content

Commit a075e7f

Browse files
committed
Correctly implement Sendable conformance rather than just silencing the compiler.
1 parent 03ad414 commit a075e7f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Sources/Fluent/FluentProvider.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import ConsoleKit
22
import NIOCore
33
import NIOPosix
4+
import NIOConcurrencyHelpers
45
import Logging
56
import Vapor
6-
import FluentKit
7+
@preconcurrency import FluentKit
78

89
extension Request {
910
public var db: any Database {
@@ -78,18 +79,18 @@ extension Application {
7879
}
7980

8081
public struct Fluent {
81-
final class Storage: @unchecked Sendable {
82+
final class Storage: Sendable {
8283
let databases: Databases
8384
let migrations: Migrations
84-
var migrationLogLevel: Logger.Level
85+
let migrationLogLevel: NIOLockedValueBox<Logger.Level>
8586

8687
init(threadPool: NIOThreadPool, on eventLoopGroup: any EventLoopGroup, migrationLogLevel: Logger.Level) {
8788
self.databases = Databases(
8889
threadPool: threadPool,
8990
on: eventLoopGroup
9091
)
9192
self.migrations = .init()
92-
self.migrationLogLevel = migrationLogLevel
93+
self.migrationLogLevel = .init(migrationLogLevel)
9394
}
9495
}
9596

@@ -143,8 +144,8 @@ extension Application {
143144
}
144145

145146
public var migrationLogLevel: Logger.Level {
146-
get { self.storage.migrationLogLevel }
147-
nonmutating set { self.storage.migrationLogLevel = newValue }
147+
get { self.storage.migrationLogLevel.withLockedValue { $0 } }
148+
nonmutating set { self.storage.migrationLogLevel.withLockedValue { $0 = newValue } }
148149
}
149150

150151
public var history: History {

0 commit comments

Comments
 (0)