Skip to content

Conversation

@simolus3
Copy link
Contributor

This adds an option to pass in powersync_control('start', ...) that will make the sync client emit diagnostic events as instructions to the client SDK.

This is a step towards #155: As we deprecate non-Rust clients from our SDKs, it makes sense to move diagnostic reporting into the core extension instead of requiring SDKs to parse and handle sync lines for that.

Currently, the diagnostic module patches the sync client to:

  1. Track progress on a per-bucket level (the SDK only emits progress per priority).
  2. Infer a schema based on actual data that has been downloaded (by parsing oplog data).
  3. Show the size of downloaded contents per bucket.

This PR adds steps 1 and 2 into the core extension. If diagnostics are enabled when starting a sync iteration, we emit a HandleDiagnostics instruction when:

  1. The progress or download state changes for any bucket. For efficiency, we only deliver a partial message for data lines (SDKs would keep an in-memory Map<string, BucketState> that they would patch for partial updates). A complete update is emitted when we start tracking checkpoints.
  2. We encounter a new column type in the schema for the current sync iteration. Again, diagnostic modules would store an external Map<string, Map<string, ColumnType>> map to update in response to those events. The JS diagnostic module can also keep storing that in local storage, this just replaces the notification part so that we no longer have to parse oplog lines in JS.

To expose the size of downloaded data per bucket, I believe it makes sense to alter ps_buckets instead. I'll open another PR for that.

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