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
@@ -373,11 +373,14 @@ internal final class InternalDefaultLiveMap: Sendable {
373
373
/// Applies a `MAP_REMOVE` operation to a key, per RTLM8.
374
374
///
375
375
/// 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
455
476
returniflet createOp = state.createOp {
@@ -479,10 +500,13 @@ internal final class InternalDefaultLiveMap: Sendable {
479
500
entries.map{ key, entry in
480
501
if entry.tombstone ==true{
481
502
// RTLM17a2: If ObjectsMapEntry.tombstone is true, apply the MAP_REMOVE operation
482
-
// as described in RTLM8, passing in the current key as ObjectsMapOp, and ObjectsMapEntry.timeserial as the operation's serial
503
+
// 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
483
504
applyMapRemoveOperation(
484
505
key: key,
485
506
operationTimeserial: entry.timeserial,
507
+
operationSerialTimestamp: entry.serialTimestamp,
508
+
logger: logger,
509
+
clock: clock,
486
510
)
487
511
}else{
488
512
// RTLM17a1: If ObjectsMapEntry.tombstone is false, apply the MAP_SET operation
@@ -591,6 +615,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)
660
687
688
+
// Calculate the tombstonedAt for the new or updated entry per RTLM8f
689
+
lettombstonedAt:Date?
690
+
iflet operationSerialTimestamp {
691
+
// RTLM8f1
692
+
tombstonedAt = operationSerialTimestamp
693
+
}else{
694
+
// RTLM8f2
695
+
logger.log("serialTimestamp not provided for MAP_REMOVE, using local clock for tombstone timestamp", level:.debug)
696
+
// RTLM8f2a
697
+
tombstonedAt = clock.now
698
+
}
699
+
661
700
// RTLM8a: If an entry exists in the private data for the specified key
662
701
iflet existingEntry =data[key]{
663
702
// RTLM8a1: If the operation cannot be applied as per RTLM9, discard the operation
@@ -667,17 +706,19 @@ internal final class InternalDefaultLiveMap: Sendable {
667
706
// RTLM8a2: Otherwise, apply the operation
668
707
// RTLM8a2a: Set ObjectsMapEntry.data to undefined/null
669
708
// RTLM8a2b: Set ObjectsMapEntry.timeserial to the operation's serial
670
-
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true
709
+
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true (equivalent to next point)
710
+
// RTLM8a2d: Set ObjectsMapEntry.tombstonedAt per RTLM8a2d
671
711
varupdatedEntry= existingEntry
672
712
updatedEntry.data =ObjectData()
673
713
updatedEntry.timeserial = operationTimeserial
674
-
updatedEntry.tombstone=true
714
+
updatedEntry.tombstonedAt=tombstonedAt
675
715
data[key]= updatedEntry
676
716
}else{
677
717
// RTLM8b: If an entry does not exist in the private data for the specified key
678
718
// RTLM8b1: Create a new entry in data for the specified key, with ObjectsMapEntry.data set to undefined/null and the operation's serial
679
719
// 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