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

feat: support topics sequence page #1463

Merged
merged 5 commits into from
Nov 11, 2024
Merged

feat: support topics sequence page #1463

merged 5 commits into from
Nov 11, 2024

Conversation

anitarua
Copy link
Contributor

@anitarua anitarua commented Nov 6, 2024

Work towards https://github.com/momentohq/dev-eco-issue-tracker/issues/1059

Updates the topic subscription to take the sequence page into account:

  • Keeps track of last known sequence page in addition to sequence number in SubscriptionState so we can reconnect gracefully
  • Includes sequence page detail for TopicDiscontinuity objects

As part of this change, had to update the client-protos dependency version as well.

Tested locally to verify both node and web clients gracefully reconnect when wifi is toggled and sequence page is used to resume from the next expected sequence number.
Also tested locally and confirmed that subscribing with an initial (arbitrary) sequence page will cause a discontinuity before getting assigned a new sequence page.

Also had forgotten to export TopicDiscontinuity in the web sdk in a previous PR, so that was added here as well.

@anitarua anitarua marked this pull request as ready for review November 7, 2024 18:17
@anitarua anitarua requested review from malandis and a team November 7, 2024 18:19
Copy link
Contributor

@rishtigupta rishtigupta left a comment

Choose a reason for hiding this comment

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

lgtm! :shipit:

Copy link
Contributor

@malandis malandis left a comment

Choose a reason for hiding this comment

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

Logic looks good to me. Couple suggestions to avoid null checks in the code, otherwise gtg!

packages/client-sdk-web/src/index.ts Show resolved Hide resolved
packages/client-sdk-web/src/internal/pubsub-client.ts Outdated Show resolved Hide resolved
packages/client-sdk-web/src/internal/pubsub-client.ts Outdated Show resolved Hide resolved
packages/client-sdk-nodejs/src/internal/pubsub-client.ts Outdated Show resolved Hide resolved
Comment on lines +141 to +143
this.getLogger().trace(
`Subscribing to topic with resume_at_topic_sequence_number ${options.subscriptionState.resumeAtTopicSequenceNumber} and sequence_page ${options.subscriptionState.resumeAtTopicSequencePage}`
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

while testing locally, I noticed the logs coming from the web sdk looked poorly formatted, reverted to using the string interpolation instead

[2024-11-08T18:08:38.251Z] TRACE (Momento: PubsubClient): Issuing publish request; topic: %s, message length: %stopic-web,15
[2024-11-08T18:08:38.436Z] TRACE (Momento: PubsubClient): Received an item on subscription stream; topic: %s; sequence number: %s; sequence page: %stopic-web,3,1731089315

@anitarua anitarua merged commit f32881a into main Nov 11, 2024
13 checks passed
@anitarua anitarua deleted the sequence-page branch November 11, 2024 20:00
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.

3 participants