diff --git a/Plugins/TableProPluginKit/PluginConcurrencySupport.swift b/Plugins/TableProPluginKit/PluginConcurrencySupport.swift new file mode 100644 index 000000000..1e6f74104 --- /dev/null +++ b/Plugins/TableProPluginKit/PluginConcurrencySupport.swift @@ -0,0 +1,33 @@ +import Foundation + +public func pluginDispatchAsync( + on queue: DispatchQueue, + execute work: @escaping @Sendable () throws -> T +) async throws -> T { + try await withCheckedThrowingContinuation { continuation in + queue.async { + do { + let result = try work() + continuation.resume(returning: result) + } catch { + continuation.resume(throwing: error) + } + } + } +} + +public func pluginDispatchAsync( + on queue: DispatchQueue, + execute work: @escaping @Sendable () throws -> Void +) async throws { + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + queue.async { + do { + try work() + continuation.resume() + } catch { + continuation.resume(throwing: error) + } + } + } +} diff --git a/Plugins/TableProPluginKit/PluginDriverError.swift b/Plugins/TableProPluginKit/PluginDriverError.swift new file mode 100644 index 000000000..01a2a99b9 --- /dev/null +++ b/Plugins/TableProPluginKit/PluginDriverError.swift @@ -0,0 +1,19 @@ +// +// PluginDriverError.swift +// TableProPluginKit +// + +import Foundation + +public protocol PluginDriverError: LocalizedError, Sendable { + var pluginErrorMessage: String { get } + var pluginErrorCode: Int? { get } + var pluginSqlState: String? { get } + var pluginErrorDetail: String? { get } +} + +public extension PluginDriverError { + var pluginErrorCode: Int? { nil } + var pluginSqlState: String? { nil } + var pluginErrorDetail: String? { nil } +} diff --git a/Plugins/TableProPluginKit/PluginRowLimits.swift b/Plugins/TableProPluginKit/PluginRowLimits.swift new file mode 100644 index 000000000..079759160 --- /dev/null +++ b/Plugins/TableProPluginKit/PluginRowLimits.swift @@ -0,0 +1,5 @@ +import Foundation + +public enum PluginRowLimits { + public static let defaultMax = 100_000 +}