Skip to content

Commit

Permalink
Correctly implement Sendable conformance rather than just silencing t…
Browse files Browse the repository at this point in the history
…he compiler.
  • Loading branch information
gwynne committed Jan 10, 2024
1 parent 03ad414 commit a075e7f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Sources/Fluent/FluentProvider.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ConsoleKit
import NIOCore
import NIOPosix
import NIOConcurrencyHelpers
import Logging
import Vapor
import FluentKit
@preconcurrency import FluentKit

extension Request {
public var db: any Database {
Expand Down Expand Up @@ -78,18 +79,18 @@ extension Application {
}

public struct Fluent {
final class Storage: @unchecked Sendable {
final class Storage: Sendable {
let databases: Databases
let migrations: Migrations
var migrationLogLevel: Logger.Level
let migrationLogLevel: NIOLockedValueBox<Logger.Level>

init(threadPool: NIOThreadPool, on eventLoopGroup: any EventLoopGroup, migrationLogLevel: Logger.Level) {
self.databases = Databases(
threadPool: threadPool,
on: eventLoopGroup
)
self.migrations = .init()
self.migrationLogLevel = migrationLogLevel
self.migrationLogLevel = .init(migrationLogLevel)
}
}

Expand Down Expand Up @@ -143,8 +144,8 @@ extension Application {
}

public var migrationLogLevel: Logger.Level {
get { self.storage.migrationLogLevel }
nonmutating set { self.storage.migrationLogLevel = newValue }
get { self.storage.migrationLogLevel.withLockedValue { $0 } }
nonmutating set { self.storage.migrationLogLevel.withLockedValue { $0 = newValue } }
}

public var history: History {
Expand Down

0 comments on commit a075e7f

Please sign in to comment.