Repository navigation
WithBroadcaster: publish committed row changes - #46
Merged
Merged
Conversation
…mmitted, of the writer's pre-update, commit and rollback hooks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coverage for this change: 90.6% |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved transaction-tracking defects can publish notifications for rolled-back rows or silently discard committed notifications, including when a dedicated reader rolls back.
5 open issues
What changed in this PR
Adds opt-in broadcasting of committed row changes to the ncruces SQLite driver, allowing watchers to receive notifications without triggers or explicit publish calls.
Changes:
- Introduces
WithBroadcaster, a publisher interface, and a per-table notification threshold. - Adds hook-based change tracking, row merging, savepoint handling, and shadow-table filtering.
- Documents the feature and adds tests for transactions, cascades, table filtering, and committed reads.
| File | Description |
|---|---|
README.md |
Documents broadcasting usage, guarantees, and limitations. |
opts.go |
Defines broadcaster options, Publisher, and MaxChanges. |
ncruces/pool.go |
Installs writer hooks and flushes notifications before releasing the writer. |
ncruces/fts5/fts5_test.go |
Tests exclusion of FTS5 shadow-table changes. |
ncruces/exec.go |
Adds change-tracking marks for multi-statement savepoints. |
ncruces/conn.go |
Integrates tracking with query execution and nested transactions. |
ncruces/changes.go |
Implements change collection, merging, filtering, and publication. |
ncruces/changes_test.go |
Tests notifications across writes, rollbacks, cascades, and committed reads. |
Review effort: Balanced
…nts are checked, readers don't change the writer's changes, table types are read of each flush, and tables WITHOUT ROWID aren't published Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Rows which are written are published to a broadcaster, such as go-server's
broadcaster.Broadcaster, once they're committed, like go-pg's pgbroadcaster, but without aPublishcall or triggers. SQLite has noNOTIFY, so the writer's hooks say what's written.sqlite.WithBroadcaster(b, tables...): aPublisher, with a non-blockingPublish(schema.Change) int, and the tables which are published, or all of them.schema.Change: its action,create,updateordelete, its database,main, its table, and its rowid, asRow.DELETEwithout aWHERE, rows whichINSERT OR REPLACEreplaces, and rows which a foreign key's cascade deletes.Txwithin a transaction, and a query of several statements, mark where theirs start, and forget the rows after it. The rows are forgotten before the savepoint is released, which commits it, outside of a transaction.sqlite.MaxChanges(1000) rows of a table, in a transaction, are one change of the table, without a row.pragma_table_list.WITHOUT ROWID, and savepoints written by hand in SQL, whose rolled-back rows are still published.