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
@@ -320,11 +320,14 @@ internal final class InternalDefaultLiveMap: Sendable {
320
320
/// Applies a `MAP_REMOVE` operation to a key, per RTLM8.
321
321
///
322
322
/// 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
402
423
returniflet createOp = state.createOp {
@@ -426,10 +447,13 @@ internal final class InternalDefaultLiveMap: Sendable {
426
447
entries.map{ key, entry in
427
448
if entry.tombstone ==true{
428
449
// RTLM17a2: If ObjectsMapEntry.tombstone is true, apply the MAP_REMOVE operation
429
-
// as described in RTLM8, passing in the current key as ObjectsMapOp, and ObjectsMapEntry.timeserial as the operation's serial
450
+
// 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
430
451
applyMapRemoveOperation(
431
452
key: key,
432
453
operationTimeserial: entry.timeserial,
454
+
operationSerialTimestamp: entry.serialTimestamp,
455
+
logger: logger,
456
+
clock: clock,
433
457
)
434
458
}else{
435
459
// RTLM17a1: If ObjectsMapEntry.tombstone is false, apply the MAP_SET operation
@@ -538,6 +562,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)
607
634
635
+
// Calculate the tombstonedAt for the new or updated entry per RTLM8f
636
+
lettombstonedAt:Date?
637
+
iflet operationSerialTimestamp {
638
+
// RTLM8f1
639
+
tombstonedAt = operationSerialTimestamp
640
+
}else{
641
+
// RTLM8f2
642
+
logger.log("serialTimestamp not provided for MAP_REMOVE, using local clock for tombstone timestamp", level:.debug)
643
+
// RTLM8f2a
644
+
tombstonedAt = clock.now
645
+
}
646
+
608
647
// RTLM8a: If an entry exists in the private data for the specified key
609
648
iflet existingEntry =data[key]{
610
649
// RTLM8a1: If the operation cannot be applied as per RTLM9, discard the operation
@@ -614,17 +653,19 @@ internal final class InternalDefaultLiveMap: Sendable {
614
653
// RTLM8a2: Otherwise, apply the operation
615
654
// RTLM8a2a: Set ObjectsMapEntry.data to undefined/null
616
655
// RTLM8a2b: Set ObjectsMapEntry.timeserial to the operation's serial
617
-
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true
656
+
// RTLM8a2c: Set ObjectsMapEntry.tombstone to true (equivalent to next point)
657
+
// RTLM8a2d: Set ObjectsMapEntry.tombstonedAt per RTLM8a2d
618
658
varupdatedEntry= existingEntry
619
659
updatedEntry.data =ObjectData()
620
660
updatedEntry.timeserial = operationTimeserial
621
-
updatedEntry.tombstone=true
661
+
updatedEntry.tombstonedAt=tombstonedAt
622
662
data[key]= updatedEntry
623
663
}else{
624
664
// RTLM8b: If an entry does not exist in the private data for the specified key
625
665
// RTLM8b1: Create a new entry in data for the specified key, with ObjectsMapEntry.data set to undefined/null and the operation's serial
626
666
// 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