Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a work-in-progress PR for sync streams.
Sync streams essentially consist of two features:
This PR implements a small subset of feature 1 by desugaring the unified query into the parameter / data queries we have today. That seemed like the easiest way to get started on this, but I think it's not a good approach to handle subqueries (which are not implemented in this PR). I will open a follow-up PR to implement the new syntax in a clean structure able to handle that better.
Instead, most of this PR is related to protocol changes enabling the second feature. While most of the subscription management happens on the client, there are two fundamental changes:
hasSynced
/lastSyncedAt
fields) for individual stream subscriptions. Since progress is ultimately attached to buckets, clients need enough information to associate buckets with stream subscriptions.SELECT * FROM assets WHERE id IN (request.args() -> 'asset_ids')
and a client subscribing once with{'asset_id': [1]}
and another time with{'asset_id': [1, 2]}
. Here, both subscriptions yield the bucketassets[id=1]
. We obviously don't want the bucket to be included in the checkpoint multiple times, but clients need to know that progress on bucketassets[id=1]
contributes to both stream subscriptions.Most of the logic related to the first requirement is implemented in the
sync-rules
package:SqlSyncRules.getBucketParameterQuerier
, we take an additional array of explicit stream subscriptions. When we find a matching stream, we evaluate parameter queries for each of those subscriptions. Otherwise, we evaluate the default subscription if the stream has one.In
service-core
, we:sync-rules
.sync-rules
directly - it's a bit easier to do it when building checksums because we need access to all buckets (static and dynamic) to do this.This is still missing tests, but I wanted to get it out for an initial discussion.