Skip to content

Commit b7cac24

Browse files
committed
feat: add shared PluginKit types (error protocol, row limits, async utility)
1 parent 38be65b commit b7cac24

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Foundation
2+
3+
public func pluginDispatchAsync<T: Sendable>(
4+
on queue: DispatchQueue,
5+
execute work: @escaping @Sendable () throws -> T
6+
) async throws -> T {
7+
try await withCheckedThrowingContinuation { continuation in
8+
queue.async {
9+
do {
10+
let result = try work()
11+
continuation.resume(returning: result)
12+
} catch {
13+
continuation.resume(throwing: error)
14+
}
15+
}
16+
}
17+
}
18+
19+
public func pluginDispatchAsync(
20+
on queue: DispatchQueue,
21+
execute work: @escaping @Sendable () throws -> Void
22+
) async throws {
23+
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
24+
queue.async {
25+
do {
26+
try work()
27+
continuation.resume()
28+
} catch {
29+
continuation.resume(throwing: error)
30+
}
31+
}
32+
}
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// PluginDriverError.swift
3+
// TableProPluginKit
4+
//
5+
6+
import Foundation
7+
8+
public protocol PluginDriverError: LocalizedError, Sendable {
9+
var pluginErrorMessage: String { get }
10+
var pluginErrorCode: Int? { get }
11+
var pluginSqlState: String? { get }
12+
var pluginErrorDetail: String? { get }
13+
}
14+
15+
public extension PluginDriverError {
16+
var pluginErrorCode: Int? { nil }
17+
var pluginSqlState: String? { nil }
18+
var pluginErrorDetail: String? { nil }
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
public enum PluginRowLimits {
4+
public static let defaultMax = 100_000
5+
}

0 commit comments

Comments
 (0)