File tree Expand file tree Collapse file tree 5 files changed +120
-0
lines changed Expand file tree Collapse file tree 5 files changed +120
-0
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ enum OpType : Int , Codable {
4+ case clear = 1
5+ case move = 2
6+ case put = 3
7+ case remove = 4
8+ }
9+
10+ extension OpType : CustomStringConvertible {
11+ var description : String {
12+ return " \( self . rawValue) "
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ struct OplogEntry : Codable , Equatable {
4+ let checksum : Int64
5+ let opId : String
6+ let rowId : String ?
7+ let rowType : String ?
8+ let op : OpType . RawValue ?
9+ let subkey : String ?
10+ let data : String ?
11+
12+ enum CodingKeys : String , CodingKey {
13+ case checksum
14+ case opId = " op_id "
15+ case rowId = " object_id "
16+ case rowType = " object_type "
17+ case op
18+ case subkey
19+ case data
20+ }
21+
22+ init (
23+ checksum: Int64 ,
24+ opId: String ,
25+ rowId: String ? = nil ,
26+ rowType: String ? = nil ,
27+ op: OpType . RawValue ? = nil ,
28+ subkey: String ? = nil ,
29+ data: String ? = nil
30+ ) {
31+ self . checksum = checksum
32+ self . opId = opId
33+ self . rowId = rowId
34+ self . rowType = rowType
35+ self . op = op
36+ self . subkey = subkey
37+ self . data = data
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ actor SharedPendingDeletesActor {
4+ private( set) var pendingBucketDeletes : Bool
5+
6+ init ( initialValue: Bool = false ) {
7+ self . pendingBucketDeletes = initialValue
8+ }
9+
10+ func setPendingBucketDeletes( _ value: Bool ) {
11+ pendingBucketDeletes = value
12+ }
13+
14+ func getPendingBucketDeletes( ) -> Bool {
15+ return pendingBucketDeletes
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ struct WriteCheckpointResponse : Codable {
4+ let data : WriteCheckpointData
5+ }
6+
7+ struct WriteCheckpointData : Codable {
8+ let writeCheckpoint : String
9+
10+ enum CodingKeys : String , CodingKey {
11+ case writeCheckpoint = " write_checkpoint "
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ /// Type of local change.
4+ public enum UpdateType {
5+ /// Insert or replace a row. All non-null columns are included in the data.
6+ case put
7+
8+ /// Update a row if it exists. All updated columns are included in the data.
9+ case patch
10+
11+ /// Delete a row if it exists.
12+ case delete
13+
14+ /// The JSON string representation of the update type
15+ private var json : String {
16+ switch self {
17+ case . put: return " PUT "
18+ case . patch: return " PATCH "
19+ case . delete: return " DELETE "
20+ }
21+ }
22+
23+ /// Convert the update type to its JSON string representation
24+ public func toJSON( ) -> String {
25+ return json
26+ }
27+
28+ /// Create an UpdateType from a JSON string, returning nil if the string doesn't match any known type
29+ public static func fromJSON( _ json: String ) -> UpdateType ? {
30+ switch json {
31+ case " PUT " : return . put
32+ case " PATCH " : return . patch
33+ case " DELETE " : return . delete
34+ default : return nil
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments