diff --git a/Sources/XyoClient/Panel/Panel.swift b/Sources/XyoClient/Panel/Panel.swift index 7412ceb..ff8577c 100644 --- a/Sources/XyoClient/Panel/Panel.swift +++ b/Sources/XyoClient/Panel/Panel.swift @@ -6,13 +6,13 @@ public enum XyoPanelError: Error { public class XyoPanel { - public init(archivists: [XyoArchivistApiClient], witnesses: [AbstractWitness]) { + public init(archivists: [XyoArchivistApiClient], witnesses: [AbstractSyncWitness]) { self._archivists = archivists self._witnesses = witnesses } public convenience init( - archive: String? = nil, apiDomain: String? = nil, witnesses: [AbstractWitness]? = nil, + archive: String? = nil, apiDomain: String? = nil, witnesses: [AbstractSyncWitness]? = nil, token: String? = nil ) { let apiConfig = XyoArchivistApiConfig( @@ -23,7 +23,7 @@ public class XyoPanel { public convenience init(observe: (() -> XyoEventPayload?)?) { if observe != nil { - var witnesses = [AbstractWitness]() + var witnesses = [AbstractSyncWitness]() if let observe = observe { witnesses.append(XyoEventWitness(observe)) @@ -38,9 +38,9 @@ public class XyoPanel { public typealias XyoPanelReportCallback = (([String]) -> Void) private var _archivists: [XyoArchivistApiClient] - private var _witnesses: [AbstractWitness] + private var _witnesses: [AbstractSyncWitness] private var _previous_hash: String? - + @available(iOS 15, *) public func report() async throws -> [Payload] diff --git a/Sources/XyoClient/Witness/AbstractWitness.swift b/Sources/XyoClient/Witness/AbstractWitness.swift index bb63185..6712b1e 100644 --- a/Sources/XyoClient/Witness/AbstractWitness.swift +++ b/Sources/XyoClient/Witness/AbstractWitness.swift @@ -1,6 +1,6 @@ import Foundation -open class AbstractWitness: AbstractModule, WitnessSync { +open class AbstractSyncWitness: AbstractModule, WitnessSync { open func observe() -> [Payload] { preconditionFailure("This method must be overridden") } @@ -26,3 +26,8 @@ open class AbstractAsyncWitness: AbstractModule, WitnessAsync { } } } + +public protocol Witness {} + +extension AbstractSyncWitness: Witness {} +extension AbstractAsyncWitness: Witness {} diff --git a/Sources/XyoClient/Witness/Basic/BasicWitness.swift b/Sources/XyoClient/Witness/Basic/BasicWitness.swift index 2fd06c7..ec1acc9 100644 --- a/Sources/XyoClient/Witness/Basic/BasicWitness.swift +++ b/Sources/XyoClient/Witness/Basic/BasicWitness.swift @@ -1,6 +1,6 @@ import Foundation -open class BasicWitness: AbstractWitness { +open class BasicWitness: AbstractSyncWitness { public typealias TPayloadOut = Payload diff --git a/Sources/XyoClient/Witness/Event/EventWitness.swift b/Sources/XyoClient/Witness/Event/EventWitness.swift index dd59e42..5e5e12e 100644 --- a/Sources/XyoClient/Witness/Event/EventWitness.swift +++ b/Sources/XyoClient/Witness/Event/EventWitness.swift @@ -1,6 +1,6 @@ import Foundation -open class XyoEventWitness: AbstractWitness { +open class XyoEventWitness: AbstractSyncWitness { public init(_ observer: @escaping ObserverClosure) { _observer = observer diff --git a/Sources/XyoClient/Witness/SystemInfo/SystemInfoWitness.swift b/Sources/XyoClient/Witness/SystemInfo/SystemInfoWitness.swift index 5814dd0..9053cb7 100644 --- a/Sources/XyoClient/Witness/SystemInfo/SystemInfoWitness.swift +++ b/Sources/XyoClient/Witness/SystemInfo/SystemInfoWitness.swift @@ -1,6 +1,6 @@ import Foundation -open class SystemInfoWitness: AbstractWitness { +open class SystemInfoWitness: AbstractSyncWitness { var allowPathMonitor: Bool diff --git a/Sources/XyoClient/Witness/WitnessSync.swift b/Sources/XyoClient/Witness/Witness.swift similarity index 57% rename from Sources/XyoClient/Witness/WitnessSync.swift rename to Sources/XyoClient/Witness/Witness.swift index 2ca7579..abc0600 100644 --- a/Sources/XyoClient/Witness/WitnessSync.swift +++ b/Sources/XyoClient/Witness/Witness.swift @@ -1,15 +1,10 @@ -public protocol WitnessProtocol {} - - -public protocol WitnessSync: WitnessProtocol { +public protocol WitnessSync { func observe() -> [Payload] } -public protocol WitnessAsync: WitnessProtocol { +public protocol WitnessAsync { func observe(completion: @escaping ([Payload]?, Error?) -> Void) @available(iOS 15, *) func observe() async throws -> [Payload] } - - diff --git a/Tests/XyoClientTests/Panel.swift b/Tests/XyoClientTests/Panel.swift index fd2b018..b3bb9de 100644 --- a/Tests/XyoClientTests/Panel.swift +++ b/Tests/XyoClientTests/Panel.swift @@ -17,7 +17,7 @@ final class PanelTests: XCTestCase { let apiDomain = XyoPanel.Defaults.apiDomain let archive = XyoPanel.Defaults.apiModule let account = Account() - let witness = AbstractWitness(account: account) + let witness = AbstractSyncWitness(account: account) let panel = XyoPanel(archive: archive, apiDomain: apiDomain, witnesses: [witness]) XCTAssertNotNil(account) XCTAssertNotNil(panel)