Skip to content

Commit

Permalink
Adopt Async APIs (#98)
Browse files Browse the repository at this point in the history
* Bump dependencies and drop 5.8

* Adopt new APIs

* Fix Swift 6 warning
  • Loading branch information
0xTim authored Oct 6, 2024
1 parent 9cc162d commit 6e3a5ff
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 55 deletions.
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -13,7 +13,7 @@ let package = Package(
.library(name: "FluentSQLiteDriver", targets: ["FluentSQLiteDriver"]),
],
dependencies: [
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.4"),
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.49.0"),
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.5.1"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
],
Expand All @@ -40,6 +40,9 @@ let package = Package(
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency=complete"),
] }
48 changes: 0 additions & 48 deletions Package@swift-5.9.swift

This file was deleted.

4 changes: 4 additions & 0 deletions Sources/FluentSQLiteDriver/FluentSQLiteDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct FluentSQLiteDriver: DatabaseDriver {
func shutdown() {
try? self.pool.syncShutdownGracefully()
}

func shutdownAsync() async {
try? await self.pool.shutdownAsync()
}
}

struct ConnectionPoolSQLiteDatabase: SQLiteDatabase {
Expand Down
9 changes: 8 additions & 1 deletion Sources/FluentSQLiteDriver/SQLiteError+Database.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import SQLiteNIO
import FluentKit

extension SQLiteError: DatabaseError {
// Required for Database Error
extension SQLiteError {
public var isSyntaxError: Bool {
switch self.reason {
case .error, .schema:
Expand Down Expand Up @@ -32,3 +33,9 @@ extension SQLiteError: DatabaseError {
}
}
}

#if compiler(<6)
extension SQLiteError: DatabaseError { }
#else
extension SQLiteError: @retroactive DatabaseError { }
#endif
8 changes: 4 additions & 4 deletions Tests/FluentSQLiteDriverTests/FluentSQLiteDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ final class FluentSQLiteDriverTests: XCTestCase {
self.dbs.use(.sqlite(.file(self.benchmarkPath)), as: .init(string: "benchmark"))
self.database = self.dbs.database(.sqlite, logger: .init(label: "test.fluent.sqlite"), on: MultiThreadedEventLoopGroup.singleton.any())
}

override func tearDownWithError() throws {
self.dbs.shutdown()
override func tearDown() async throws {
await self.dbs.shutdownAsync()
self.dbs = nil
try super.tearDownWithError()
try await super.tearDown()
}
}

Expand Down

0 comments on commit 6e3a5ff

Please sign in to comment.