You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift
+52-11Lines changed: 52 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -341,11 +341,14 @@ internal final class InternalDefaultLiveMap: Sendable {
341
341
/// Applies a `MAP_REMOVE` operation to a key, per RTLM8.
342
342
///
343
343
/// This is currently exposed just so that the tests can test RTLM8 without having to go through a convoluted replaceData(…) call, but I _think_ that it's going to be used in further contexts when we introduce the handling of incoming object operations in a future spec PR.
// RTLM6d: If ObjectState.createOp is present, merge the initial value into the LiveMap as described in RTLM17
423
444
returniflet createOp = state.createOp {
@@ -447,10 +468,13 @@ internal final class InternalDefaultLiveMap: Sendable {
447
468
entries.map{ key, entry in
448
469
if entry.tombstone ==true{
449
470
// RTLM17a2: If ObjectsMapEntry.tombstone is true, apply the MAP_REMOVE operation
450
-
// as described in RTLM8, passing in the current key as ObjectsMapOp, and ObjectsMapEntry.timeserial as the operation's serial
471
+
// as described in RTLM8, passing in the current key as ObjectsMapOp, ObjectsMapEntry.timeserial as the operation's serial, and ObjectsMapEntry.serialTimestamp as the operation's serial timestamp
451
472
applyMapRemoveOperation(
452
473
key: key,
453
474
operationTimeserial: entry.timeserial,
475
+
operationSerialTimestamp: entry.serialTimestamp,
476
+
logger: logger,
477
+
clock: clock,
454
478
)
455
479
}else{
456
480
// RTLM17a1: If ObjectsMapEntry.tombstone is false, apply the MAP_SET operation
@@ -559,6 +583,9 @@ internal final class InternalDefaultLiveMap: Sendable {
// (Note that, where the spec tells us to set ObjectsMapEntry.data to nil, we actually set it to an empty ObjectData, which is equivalent, since it contains no data)
628
655
656
+
// Calculate the tombstonedAt for the new or updated entry per RTLM8f
657
+
lettombstonedAt:Date?
658
+
iflet operationSerialTimestamp {
659
+
// RTLM8f1
660
+
tombstonedAt = operationSerialTimestamp
661
+
}else{
662
+
// RTLM8f2
663
+
logger.log("serialTimestamp not provided for MAP_REMOVE, using local clock for tombstone timestamp", level:.debug)
664
+
// RTLM8f2a
665
+
tombstonedAt = clock.now
666
+
}
667
+
629
668
// RTLM8a: If an entry exists in the private data for the specified key
630
669
iflet existingEntry =data[key]{
631
670
// RTLM8a1: If the operation cannot be applied as per RTLM9, discard the operation
@@ -635,17 +674,19 @@ internal final class InternalDefaultLiveMap: Sendable {
635
674
// RTLM8a2: Otherwise, apply the operation
636
675
// RTLM8a2a: Set ObjectsMapEntry.data to undefined/null
637
676
// RTLM8a2b: Set ObjectsMapEntry.timeserial to the operation's serial
638
-
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true
677
+
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true (equivalent to next point)
678
+
// RTLM8a2d: Set ObjectsMapEntry.tombstonedAt per RTLM8a2d
639
679
varupdatedEntry= existingEntry
640
680
updatedEntry.data =ObjectData()
641
681
updatedEntry.timeserial = operationTimeserial
642
-
updatedEntry.tombstone=true
682
+
updatedEntry.tombstonedAt=tombstonedAt
643
683
data[key]= updatedEntry
644
684
}else{
645
685
// RTLM8b: If an entry does not exist in the private data for the specified key
646
686
// RTLM8b1: Create a new entry in data for the specified key, with ObjectsMapEntry.data set to undefined/null and the operation's serial
647
687
// RTLM8b2: Set ObjectsMapEntry.tombstone for the new entry to true
Copy file name to clipboardExpand all lines: Sources/AblyLiveObjects/Internal/InternalObjectsMapEntry.swift
+11-4Lines changed: 11 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,20 @@
1
-
/// The entries stored in a `LiveMap`'s data. Same as an `ObjectsMapEntry` but with an additional `tombstonedAt` property, per RTLM3a. (This property will be added in an upcoming commit.)
1
+
import Foundation
2
+
3
+
/// The entries stored in a `LiveMap`'s data. Same as an `ObjectsMapEntry` but with an additional `tombstonedAt` property, per RTLM3a.
2
4
internalstructInternalObjectsMapEntry{
3
-
internalvartombstone:Bool? // OME2a
5
+
internalvartombstonedAt:Date? // RTLM3a
6
+
internalvartombstone:Bool{
7
+
// TODO: Confirm that we don't need to store this (https://github.com/ably/specification/pull/350/files#r2213895661)
0 commit comments