Skip to content

Commit 9259335

Browse files
committed
Clarify the default values for newly created LiveMap and LiveCounter in RTLM4 and RTLC4
Also remove the term "zero-value" object as it is an unnecessary detail that simply describes a newly created object according to RTLM4 and RTLC4
1 parent cb11ba8 commit 9259335

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

textile/objects-features.textile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ h3(#realtime-objects). RealtimeObjects
5858
*** @(RTO11h1)@ While waiting for the publish operation to complete in "RTO11g1":#RTO11g1, the client library may have already received the echoed @ObjectMessage@ operation, as it could arrive before the @ACK@ for the publish operation. Depending on the threading and/or asynchronous model of the client library, this could mean that the @ObjectMessage@ for the @MAP_CREATE@ operation has already been processed, and the new @LiveMap@ instance already exists in the internal @ObjectsPool@. As such, the following checks are performed to determine whether the instance already exists
5959
*** @(RTO11h2)@ If an object with the @ObjectMessage.operation.objectId@ exists in the internal @ObjectsPool@, return it
6060
*** @(RTO11h3)@ Otherwise, if the object does not exist in the internal @ObjectsPool@:
61-
**** @(RTO11h3a)@ Create a zero-value @LiveMap@ (per "RTLM4":#RTLM4), set its @objectId@ to @ObjectMessage.operation.objectId@, set its @semantics@ to @ObjectMessage.operation.map.semantics@, and merge the initial value as described in "RTLM17":#RTLM17, passing in @ObjectMessage.operation@
61+
**** @(RTO11h3a)@ Create a new @LiveMap@ (per "RTLM4":#RTLM4) by passing in @ObjectMessage.operation.objectId@ as @objectId@, @ObjectMessage.operation.map.semantics@ as @semantics@, and then merge the initial value as described in "RTLM17":#RTLM17, passing in @ObjectMessage.operation@
6262
**** @(RTO11h3b)@ Add the created @LiveMap@ instance to the internal @ObjectsPool@
6363
**** @(RTO11h3c)@ Return the created @LiveMap@ instance
6464
* @(RTO12)@ @RealtimeObjects#createCounter@ function:
@@ -88,7 +88,7 @@ h3(#realtime-objects). RealtimeObjects
8888
*** @(RTO12h1)@ While waiting for the publish operation to complete in "RTO12g1":#RTO12g1, the client library may have already received the echoed @ObjectMessage@ operation, as it could arrive before the @ACK@ for the publish operation. Depending on the threading and/or asynchronous model of the client library, this could mean that the @ObjectMessage@ for the @COUNTER_CREATE@ operation has already been processed, and the new @LiveCounter@ instance already exists in the internal @ObjectsPool@. As such, the following checks are performed to determine whether the instance already exists
8989
*** @(RTO12h2)@ If an object with the @ObjectMessage.operation.objectId@ exists in the internal @ObjectsPool@, return it
9090
*** @(RTO12h3)@ Otherwise, if the object does not exist in the internal @ObjectsPool@:
91-
**** @(RTO12h3a)@ Create a zero-value @LiveCounter@ (per "RTLC4":#RTLC4), set its @objectId@ to @ObjectMessage.operation.objectId@, and merge the initial value as described in "RTLC10":#RTLC10, passing in @ObjectMessage.operation@
91+
**** @(RTO12h3a)@ Create a new @LiveCounter@ (per "RTLC4":#RTLC4) by passing in @ObjectMessage.operation.objectId@ as @objectId@, and then merge the initial value as described in "RTLC10":#RTLC10, passing in @ObjectMessage.operation@
9292
**** @(RTO12h3b)@ Add the created @LiveCounter@ instance to the internal @ObjectsPool@
9393
**** @(RTO12h3c)@ Return the created @LiveCounter@ instance
9494
* @(RTO2)@ Various object operations may require a specific channel mode to be set on a channel in order to be performed. If a specific channel mode is required by an operation, then:
@@ -105,7 +105,7 @@ h3(#realtime-objects). RealtimeObjects
105105
** @(RTO4a)@ If the @HAS_OBJECTS@ flag is 1, the server will shortly perform an @OBJECT_SYNC@ sequence as described in "RTO5":#RTO5
106106
** @(RTO4b)@ If the @HAS_OBJECTS@ flag is 0 or there is no @flags@ field, the sync sequence must be considered complete immediately, and the client library must perform the following actions in order:
107107
*** @(RTO4b1)@ All objects except the one with id @root@ must be removed from the internal @ObjectsPool@
108-
*** @(RTO4b2)@ The data for the @LiveMap@ with id @root@ must be cleared by setting it to a zero-value per "RTLM4":#RTLM4
108+
*** @(RTO4b2)@ The data for the @LiveMap@ with id @root@ must be cleared by setting it to an empty map per "RTLM4c":#RTLM4c
109109
**** @(RTO4b2a)@ Emit a @LiveMapUpdate@ object for the @LiveMap@ with ID @root@, with @LiveMapUpdate.update@ consisting of entries for the keys that were removed, each set to @removed@
110110
*** @(RTO4b3)@ The @SyncObjectsPool@ list must be cleared
111111
*** @(RTO4b5)@ The @BufferedObjectOperations@ list must be cleared
@@ -127,8 +127,8 @@ h3(#realtime-objects). RealtimeObjects
127127
***** @(RTO5c1a2)@ Store the @LiveObjectUpdate@ object returned by the operation, along with a reference to the updated object
128128
**** @(RTO5c1b)@ If an object with @ObjectState.objectId@ does not exist in the internal @ObjectsPool@:
129129
***** @(RTO5c1b1)@ Create a new @LiveObject@ using the data from @ObjectState@ and add it to the internal @ObjectsPool@:
130-
****** @(RTO5c1b1a)@ If @ObjectState.counter@ is present, create a zero-value @LiveCounter@ (per "RTLC4":#RTLC4), set its private @objectId@ equal to @ObjectState.objectId@ and override its internal data using the current @ObjectState@ per "RTLC6":#RTLC6
131-
****** @(RTO5c1b1b)@ If @ObjectState.map@ is present, create a zero-value @LiveMap@ (per "RTLM4":#RTLM4), set its private @objectId@ equal to @ObjectState.objectId@, set its private @semantics@ equal to @ObjectState.map.semantics@ and override its internal data using the current @ObjectState@ per "RTLM6":#RTLM6
130+
****** @(RTO5c1b1a)@ If @ObjectState.counter@ is present, create a new @LiveCounter@ (per "RTLC4":#RTLC4) by passing in @ObjectState.objectId@ as @objectId@, and then override its internal data using the current @ObjectState@ per "RTLC6":#RTLC6
131+
****** @(RTO5c1b1b)@ If @ObjectState.map@ is present, create a new @LiveMap@ (per "RTLM4":#RTLM4) by passing in @ObjectState.objectId@ as @objectId@, @ObjectState.map.semantics@ as @semantics@, and then override its internal data using the current @ObjectState@ per "RTLM6":#RTLM6
132132
****** @(RTO5c1b1c)@ Otherwise, log a warning that an unsupported object state message has been received, and discard the current @ObjectState@ without taking any action
133133
*** @(RTO5c2)@ Remove any objects from the internal @ObjectsPool@ for which @objectId@s were not received during the sync sequence
134134
**** @(RTO5c2a)@ The object with ID @root@ must not be removed from @ObjectsPool@, as per "RTO3b":#RTO3b
@@ -137,12 +137,12 @@ h3(#realtime-objects). RealtimeObjects
137137
*** @(RTO5c3)@ Clear any stored sync sequence identifiers and cursor values
138138
*** @(RTO5c4)@ The @SyncObjectsPool@ must be cleared
139139
*** @(RTO5c5)@ The @BufferedObjectOperations@ list must be cleared
140-
* @(RTO6)@ When needed, a zero-value object can be created if it does not exist in the internal @ObjectsPool@ for an @objectId@, in the following way:
140+
* @(RTO6)@ When needed, a new object can be created if it does not exist in the internal @ObjectsPool@ for an @objectId@, in the following way:
141141
** @(RTO6a)@ If an object with @objectId@ exists in @ObjectsPool@, do not create a new object
142142
** @(RTO6b)@ The expected type of the object can be inferred from the provided @objectId@:
143143
*** @(RTO6b1)@ Split the @objectId@ (formatted as @[type]:[hash]@[timestamp]@, see "RTO14c":#RTO14c) on the separator @:@ and parse the first part as the type string
144-
*** @(RTO6b2)@ If the parsed type is @map@, create a zero-value @LiveMap@ per "RTLM4":#RTLM4 in the @ObjectsPool@
145-
*** @(RTO6b3)@ If the parsed type is @counter@, create a zero-value @LiveCounter@ per "RTLC4":#RTLC4 in the @ObjectsPool@
144+
*** @(RTO6b2)@ If the parsed type is @map@, create a new @LiveMap@ per "RTLM4":#RTLM4 by passing in the @objectId@, and add it to the @ObjectsPool@
145+
*** @(RTO6b3)@ If the parsed type is @counter@, create a new @LiveCounter@ per "RTLC4":#RTLC4 by passing in the @objectId@, and add it to the @ObjectsPool@
146146
* @(RTO7)@ The client library may receive @OBJECT@ @ProtocolMessages@ in realtime over the channel concurrently with @OBJECT_SYNC@ @ProtocolMessages@ during the object sync sequence ("RTO5":#RTO5). Some of the incoming @OBJECT@ messages may have already been applied to the objects described in the sync sequence, while others may not. Therefore, the client must buffer @OBJECT@ messages during the sync sequence so that it can determine which of them should be applied to the objects once the sync is complete. See "RTO8":#RTO8
147147
** @(RTO7a)@ An internal @BufferedObjectOperations@ should be used to store the buffered @ObjectMessages@, as described in "RTO8a":#RTO8a. @BufferedObjectOperations@ is an array of @ObjectMessage@ instances
148148
*** @(RTO7a1)@ This array is empty upon @RealtimeObjects@ initialization
@@ -154,7 +154,7 @@ h3(#realtime-objects). RealtimeObjects
154154
*** @(RTO9a1)@ If @ObjectMessage.operation@ is null or omitted, log a warning indicating that an unsupported object operation message has been received, and discard the current @ObjectMessage@ without taking any action
155155
*** @(RTO9a2)@ The @ObjectMessage.operation.action@ field (see "@ObjectOperationAction@":../features#OOP2) determines the type of operation to apply:
156156
**** @(RTO9a2a)@ If @ObjectMessage.operation.action@ is one of the following: @MAP_CREATE@, @MAP_SET@, @MAP_REMOVE@, @COUNTER_CREATE@, @COUNTER_INC@, or @OBJECT_DELETE@, then:
157-
***** @(RTO9a2a1)@ If it does not already exist, create a zero-value @LiveObject@ in the internal @ObjectsPool@ per "RTO6":#RTO6 using the @objectId@ from @ObjectMessage.operation.objectId@
157+
***** @(RTO9a2a1)@ If it does not already exist, create a new @LiveObject@ in the internal @ObjectsPool@ per "RTO6":#RTO6 using the @objectId@ from @ObjectMessage.operation.objectId@
158158
***** @(RTO9a2a2)@ Get the @LiveObject@ instance from the internal @ObjectsPool@ using the @objectId@ from @ObjectMessage.operation.objectId@
159159
***** @(RTO9a2a3)@ Apply the @ObjectMessage.operation@ to the @LiveObject@; see "RTLC7":#RTLC7, "RTLM15":#RTLM15
160160
**** @(RTO9a2b)@ Otherwise, log a warning that an object operation message with an unsupported action has been received, and discard the current @ObjectMessage@ without taking any action
@@ -254,7 +254,7 @@ h3(#liveobject). LiveObject
254254
**** @(RTLO4e3a)@ Set it equal to @ObjectMessage.serialTimestamp@ if it exists
255255
**** @(RTLO4e3b)@ Otherwise, set it to the current time using the local clock
256256
***** @(RTLO4e3b1)@ Log a debug or trace message indicating that @serialTimestamp@ was not found in the message and the local clock is being used instead for the tombstone timestamp
257-
*** @(RTLO4e4)@ Set the data for the @LiveObject@ to a zero-value, as described in "RTLC4":#RTLC4 or "RTLM4":#RTLM4 depending on the object type
257+
*** @(RTLO4e4)@ Clear the internal data of the @LiveObject@ as described in "RTLC4b":#RTLC4b or "RTLM4c":#RTLM4c, depending on the object type
258258
* @(RTLO5)@ An @OBJECT_DELETE@ operation can be applied to a @LiveObject@ in the following way:
259259
** @(RTLO5a)@ Expects the following arguments:
260260
*** @(RTLO5a1)@ @ObjectMessage@
@@ -265,7 +265,9 @@ h3(#livecounter). LiveCounter
265265
* @(RTLC1)@ The @LiveCounter@ extends @LiveObject@
266266
* @(RTLC2)@ Represents the counter object type for Object IDs of type @counter@
267267
* @(RTLC3)@ Holds a 64-bit floating-point number as a private @data@
268-
* @(RTLC4)@ The zero-value @LiveCounter@ is a @LiveCounter@ with @data@ set to 0
268+
* @(RTLC4)@ A new @LiveCounter@ can be created with the following values:
269+
** @(RTLC4a)@ @objectId@ is passed into the constructor and set upon creation
270+
** @(RTLC4b)@ @data@ is set to 0
269271
* @(RTLC11)@ Data updates for a @LiveCounter@ are emitted using the @LiveCounterUpdate@ object:
270272
** @(RTLC11a)@ @LiveCounterUpdate@ extends @LiveObjectUpdate@
271273
** @(RTLC11b)@ @LiveCounterUpdate.update@ has the following properties:
@@ -342,7 +344,10 @@ h3(#livemap). LiveMap
342344
* @(RTLM3)@ Holds a @Dict<String, ObjectsMapEntry>@ as a private @data@ map
343345
** @(RTLM3a)@ @ObjectsMapEntry@ entries in a @LiveMap@ have the following attributes in addition to those defined in "OME2":../features#OME2:
344346
*** @(RTLM3a1)@ @tombstonedAt@ number - a timestamp indicating when this map entry was tombstoned
345-
* @(RTLM4)@ The zero-value @LiveMap@ is a @LiveMap@ with @data@ set to an empty map
347+
* @(RTLM4)@ A new @LiveMap@ can be created with the following values:
348+
** @(RTLM4a)@ @objectId@ is passed into the constructor and set upon creation
349+
** @(RTLM4b)@ @semantics@ may be passed into the constructor and set upon creation; if not provided, it defaults to "@ObjectsMapSemantics.LWW@":../features#OMP2
350+
** @(RTLM4c)@ @data@ is set to an empty map
346351
* @(RTLM18)@ Data updates for a @LiveMap@ are emitted using the @LiveMapUpdate@ object:
347352
** @(RTLM18a)@ @LiveMapUpdate@ extends @LiveObjectUpdate@
348353
** @(RTLM18b)@ @LiveMapUpdate.update@ is of type @Dict<String, 'updated' | 'removed'>@ - a map of @LiveMap@ keys that were either updated or removed, with the corresponding value indicating the type of change for each key
@@ -475,7 +480,7 @@ h3(#livemap). LiveMap
475480
*** @(RTLM7b2)@ Set @ObjectsMapEntry.tombstone@ for the new entry to @false@
476481
*** @(RTLM7b3)@ Set @ObjectsMapEntry.tombstonedAt@ for the new entry to undefined/null
477482
** @(RTLM7c)@ If the operation has a non-empty @ObjectData.objectId@ attribute:
478-
*** @(RTLM7c1)@ Create a zero-value @LiveObject@ in the internal @ObjectsPool@ per "RTO6":#RTO6
483+
*** @(RTLM7c1)@ Create a new @LiveObject@ in the internal @ObjectsPool@ per "RTO6":#RTO6
479484
** @(RTLM7f)@ Return a @LiveMapUpdate@ object with a @LiveMapUpdate.update@ map containing the key used in this operation set to @updated@
480485
* @(RTLM8)@ A @MAP_REMOVE@ operation for a key can be applied to a @LiveMap@ in the following way:
481486
** @(RTLM8c)@ Expects the following arguments:

0 commit comments

Comments
 (0)