Skip to content

Sync streams #112

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Sync streams #112

wants to merge 18 commits into from

Conversation

simolus3
Copy link
Contributor

This adds support for sync streams to the core extension.

Local sync stream subscriptions are managed by invoking powersync_control('subscriptions', ...), where the second argument can be used to

  • subscribe to a stream, supplying its name, parameters to use for the subscription and optionally a TTL + priority.
  • unsubscribe from a stream by its name and parameters.

Stream subscriptions are stored in a new ps_stream_subscriptions table (with the stream's name and subscription parameters being the primary key). Rows are created

  • when a stream is subscribed to explicitly.
  • when we receive a stream from the sync service by default

It's also possible to explicitly subscribe to a default stream by not supplying any parameters - this is useful to e.g. override the priority of such a stream. Another reason for storing default streams is that they should be visible when a user requests a list of all streams. We also store whether a particular stream has been synced (and when it has last been synced).

Finally, the sync status interface is expanded to include information about all streams part of the current sync information. We also include all bucket names for each stream here, which is useful for client SDKs to compute sync progress for each stream.

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.

1 participant