-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sequence number to TopicItem and add optional onDiscontinui…
…ty callback (#1418) * feat: add sequence number to TopicItem * feat: add optional onDiscontinuity handler
- Loading branch information
Showing
8 changed files
with
114 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/core/src/messages/responses/topic-discontinuity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Represents a discontinuity in a topic subscription. | ||
* | ||
* @remarks A subscription is created by calling {@link TopicClient.subscribe}. | ||
*/ | ||
export class TopicDiscontinuity { | ||
private readonly _lastSequenceNumber: number; | ||
private readonly _newSequenceNumber: number; | ||
|
||
constructor(_lastSequenceNumber: number, _newSequenceNumber: number) { | ||
this._lastSequenceNumber = _lastSequenceNumber; | ||
this._newSequenceNumber = _newSequenceNumber; | ||
} | ||
|
||
/** | ||
* Returns the last sequence number before the discontinuity. | ||
* @returns number | ||
*/ | ||
public lastSequenceNumber(): number { | ||
return this._lastSequenceNumber; | ||
} | ||
|
||
/** | ||
* Returns the new sequence number after the discontinuity. | ||
* @returns number | ||
*/ | ||
public newSequenceNumber(): number { | ||
return this._newSequenceNumber; | ||
} | ||
|
||
public toString(): string { | ||
const displayValue = `Last Sequence Number: ${this._lastSequenceNumber}; New Sequence Number: ${this._newSequenceNumber}`; | ||
return `${this.constructor.name}: ${displayValue}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters