-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseServiceSQLite.swift
More file actions
48 lines (40 loc) · 1.13 KB
/
DatabaseServiceSQLite.swift
File metadata and controls
48 lines (40 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// DatabaseServiceSQLite.swift
// feather-database-sqlite
//
// Created by Tibor Bödecs on 2026. 01. 29..
//
#if ServiceLifecycle
import SQLiteNIOExtras
import ServiceLifecycle
/// A `Service` wrapper around an `SQLiteClient`.
public struct DatabaseServiceSQLite: Service {
/// The underlying SQLite client instance.
public var client: SQLiteClient
/// Creates a new SQLite client service.
///
/// - Parameter client: The SQLite client to manage for the service lifecycle.
public init(
_ client: SQLiteClient
) {
self.client = client
}
/// Runs the SQLite client service.
///
/// This method starts the SQLite client, waits for a graceful shutdown
/// signal, and then shuts down the client in an orderly manner.
///
/// - Throws: Rethrows any error produced while starting the SQLite client.
public func run() async throws {
do {
try await client.run()
try? await gracefulShutdown()
await client.shutdown()
}
catch {
await client.shutdown()
throw error
}
}
}
#endif