Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/col 3 rewind #62

Merged
merged 24 commits into from
Oct 23, 2023
Merged

Feature/col 3 rewind #62

merged 24 commits into from
Oct 23, 2023

Conversation

mschristensen
Copy link
Collaborator

(Closed #55 as the branch name was misleading - we have not ended up using an interval-based rewind).

In fact, we aren't actually using rewind; but it's described as such in the ticket so keeping that naming here.

Instead we can use history with untilAttach to paginate back through messages to find the sequenceID boundary from which to replay messages. This can be done while preserving continuity with incoming live messages.

Other point of note: since with adbc the message ID is actually the SequenceID (a serial number) but the message ID type is a string, lexicographical ordering doesn't work for us ('2' > '10' in this case). So, we sort numerically if we can and fallback to lexicographical order when we can't.

@mschristensen mschristensen requested a review from zknill October 19, 2023 16:37
src/stream/Stream.ts Outdated Show resolved Hide resolved
src/stream/Stream.ts Outdated Show resolved Hide resolved
src/stream/Middleware.ts Outdated Show resolved Hide resolved
src/stream/Middleware.ts Outdated Show resolved Hide resolved
src/stream/Stream.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@zknill zknill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one! 💯

Adds a SequenceResumer middleware that discards messages up until the attach point given by the sequence ID is reached. Can be used in conjunction with a sliding window re-orderer via the OrderedSequenceResumer middleware.
The SyncFunc now returns the sequenceID and stateTimestamp along with
the model state snapshot. This is used by the model to rewind to the
correct point in the stream.
In order to work around rewind's 100 message limit, we can use a history query with untilAttach to paginate back through messages until the target sequenceID boundary is reached. This has the additional benefit that enabling persisted history on the channel just works, allowing you to extend your state cache TTL.
@mschristensen mschristensen merged commit 4a8d85c into main Oct 23, 2023
5 checks passed
@mschristensen mschristensen deleted the feature/COL-3-rewind branch October 23, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants