-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWatchStore.swift
More file actions
24 lines (21 loc) · 895 Bytes
/
WatchStore.swift
File metadata and controls
24 lines (21 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Foundation
import Haystack
/// Defines a storage system that allows stateful storage of system watches.
public protocol WatchStore: Sendable {
func read(watchId: String) async throws -> WatchResponse
func create(ids: [Haystack.Ref], lease: Haystack.Number?) async throws -> String
func addIds(watchId: String, ids: [Haystack.Ref]) async throws
func removeIds(watchId: String, ids: [Haystack.Ref]) async throws
func updateLastReported(watchId: String) async throws
func delete(watchId: String) async throws
}
public struct WatchResponse: Sendable {
public let ids: [Haystack.Ref]
public let lease: Haystack.Number
public let lastReported: Foundation.Date?
public init(ids: [Haystack.Ref], lease: Haystack.Number, lastReported: Foundation.Date?) {
self.ids = ids
self.lease = lease
self.lastReported = lastReported
}
}