Skip to content

Commit

Permalink
Refactor Message type to remove deletedAt and add updateSerial
Browse files Browse the repository at this point in the history
Added an updateSerial to allow LWW semantics to be applied to a message resulting from an operation.
Removed the deletedAt timestamp, we will rely only on updateSerial to apply ordering of operations.
UpdateAt will still be used, but just so clients can render a simple datetime and not have to understand/parse the serial.
  • Loading branch information
splindsay-92 committed Nov 1, 2024
1 parent 4b46254 commit 21e42ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2356,9 +2356,9 @@ export interface Message {
*/
updatedAt?: number;
/**
* If a `deletion` operation was applied to this message, this will be the timestamp the deletion occurred.
* The serial of the operation that updated this message.
*/
deletedAt?: number;
updateSerial?: string;
/**
* If this message resulted from an operation, this will contain the operation details.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/common/lib/types/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class Message {
refSerial?: string;
refType?: string;
updatedAt?: number;
deletedAt?: number;
updateSerial?: string;
operation?: API.Operation;

/**
Expand Down Expand Up @@ -378,7 +378,7 @@ class Message {
refSerial: this.refSerial,
refType: this.refType,
updatedAt: this.updatedAt,
deletedAt: this.deletedAt,
updateSerial: this.updateSerial,
operation: this.operation,
encoding,
data,
Expand Down Expand Up @@ -407,7 +407,7 @@ class Message {
if (this.refSerial) result += '; refSerial=' + this.refSerial;
if (this.refType) result += '; refType=' + this.refType;
if (this.updatedAt) result += '; updatedAt=' + this.updatedAt;
if (this.deletedAt) result += '; deletedAt=' + this.deletedAt;
if (this.updateSerial) result += '; updateSerial=' + this.updateSerial;
if (this.operation) result += '; operation=' + JSON.stringify(this.operation);
result += ']';
return result;
Expand Down

0 comments on commit 21e42ea

Please sign in to comment.