feat(plugins): external replication plugin (pull external -> internal) #72#265
Open
FishEnjoyer2025 wants to merge 1 commit into
Open
feat(plugins): external replication plugin (pull external -> internal) #72#265FishEnjoyer2025 wants to merge 1 commit into
FishEnjoyer2025 wants to merge 1 commit into
Conversation
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.
Implements pull-based external→internal replication as a plugin, per #72.
What it does
ExternalReplicationPluginpulls configured tables from the instance's externaldata source (e.g. a Supabase Postgres) into the internal Durable-Object SQLite, so
the instance can serve as a close-to-edge read replica that's queried locally instead of
round-tripping to the external database.
in the issue: a pull mechanism is a better global solution than per-provider push).
cursorColumn(
updated_at,id, …); the last value is persisted in_starbasedb_replication_stateso each run only pulls new/changed rows. Omit it to re-pull the whole table.
INSERT OR REPLACEupserts → safe to retry.batchSize, default 5000) so very large tables drain across runs.POST /replicate(all tables) andPOST /replicate/:table, admin-only.wrangler.tomlexample +scheduled()usage).Tests
8 unit tests (
vitest) — passing — covering:saved cursor (WHERE + param), resume-from-saved-cursor, and identifier quoting.
replicateTableflow with mocked execution: pull → upsert → advance + persistcursor; and the empty-result path.
Files
plugins/external-replication/index.ts— the pluginplugins/external-replication/index.test.ts— testsplugins/external-replication/README.md— usage + cron setup/claim #72