Repository navigation
feat(plugin): DataReplicationPlugin with Adapter Pattern for external database replication (#72) - #314
Open
Saik2789 wants to merge 1 commit into
Open
feat(plugin): DataReplicationPlugin with Adapter Pattern for external database replication (#72)#314Saik2789 wants to merge 1 commit into
Saik2789 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.
Resolves #72.
@algora-pbc /claim #72
Summary
Implements
DataReplicationPluginto pull data from external data sources (Postgres, MySQL, Turso, D1, StarbaseDB) into StarbaseDB's internal Durable Object SQLite database, turning the instance into a close-to-edge replica.This implementation directly addresses CTO @Brayden's architectural feedback from PR #75:
SyncAdapterwith dialect-specific adapters (PostgresSyncAdapter,MySQLSyncAdapter,GenericSyncAdapter) isolating schema introspection and query syntax.id,created_at, or custom columns) and cursor types (integer,timestamp,string) so only newer rows are fetched on subsequent pulls.PRIMARY KEYon the cursor column for idempotentINSERT OR REPLACEupserts.public.users->public_users), with an automatedbeforeQueryhook that seamlessly resolvespublic.usersqueries to internal SQLite tables.admintoken required):GET /replication/status— State and checkpoint status of all tablesGET /replication/status/:table— State of a single tablePOST /replication/sync— Trigger sync for all tables (202 Accepted)POST /replication/sync/:table— Trigger sync for a specific table (202 Accepted)DELETE /replication/state/:table— Reset checkpoint to re-sync from scratch (200 OK)GET /replication/history— Audit log of the last 50 replication runsGET /replication/history/:table— Audit log for a specific tabletmp_replication_stateandtmp_replication_historywithout aborting other tables. Sync yields the DO event loop every 100 rows to prevent starvation of concurrent requests.CronPluginfor scheduled synchronization.Test Plan
pnpm vitest run plugins/replicationpasses with 34 tests covering:replacevsignore).public.users->public_users) in adapter andbeforeQueryhook.tmp_replication_historyand checkpoint reset.pnpm prettier --checkpasses with zero formatting issues.Wallet (USDC on Base network): 0x20A0525b47f087f1Cc498cda257A0feB78D2320B