Add PostgreSQL storage driver alongside the existing redb file driver - #6
Closed
pandres95 wants to merge 14 commits into
Closed
Add PostgreSQL storage driver alongside the existing redb file driver#6pandres95 wants to merge 14 commits into
pandres95 wants to merge 14 commits into
Conversation
Splits the storage layer behind an async Storage trait so the backend can be chosen at runtime from DATABASE_URL: a postgres:// / postgresql:// URL selects the new sqlx-based PostgresStorage, anything else keeps using the existing RedbStorage file driver. Schema is created idempotently on connect for both drivers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
Superseded by #12, which reworks this against the current single-writer-actor + priority-lane + WAL-checkpoint codebase (this PR was 27 commits behind, built against the old redb-based |
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.
Summary
Storagetrait so account/deposit/sweep bookkeeping can be backed by different drivers.PostgresStoragedriver (viasqlx) selected automatically whenDATABASE_URLstarts withpostgres://orpostgresql://; any other value keeps using the existingRedbStoragefile driver..env.exampleand the README to document both URL forms.Test plan
cargo check --all-targetscargo test(17 passed, redb driver path)postgres:16-alpine), exercising everyStoragemethod end-to-end: schema bootstrap, account register/lookup/upsert, native deposit record + dedup + sweep-mark, block tracking, token metadata cache, ERC20 deposit record + bulk sweep-mark + sweep tx hash, sweep-failure tracking, zero-balance retry tracking. Also confirmed data persists correctly across a fresh connection (dedup correctly rejected a deposit already committed by a prior run).