feat(refid): add raw-SQL sqlite backend - #181
Open
sthanikan2000 wants to merge 1 commit into
Open
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adds a SQLite-backed refid.SequenceStore implementation using the pure-Go modernc.org/sqlite driver (no CGO), alongside the existing PostgreSQL backend. Same shape: DefaultTableName, Option, WithTableName, New, Migrate, and a single atomic upsert-and-increment statement for Next. SQLite only allows one writer at a time via a whole-database file lock, so New guards Next with an in-process mutex rather than mutating the caller's *sql.DB connection-pool configuration. That mutex only serializes calls made through one Store instance in one process — see the package doc's "Concurrency" section for exactly what it does and doesn't cover, and how to configure SQLite's busy_timeout for the cases it doesn't (a second connection/process sharing the same file). Useful standalone for local development and tests as a convenient refid.SequenceStore, in addition to being a second real backend.
sthanikan2000
force-pushed
the
feat/refid-sqlite-store
branch
from
September 2, 2026 10:59
3e0021f to
f4651ff
Compare
2 tasks
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
refid/store/sqlite, a secondrefid.SequenceStoreimplementation using the pure-Gomodernc.org/sqlitedriver (no CGO). Same shape asrefid/store/postgres:DefaultTableName,Option,WithTableName,New,Migrate, single atomic upsert-and-incrementNext.NewguardsNextwith an in-processsync.Mutexrather than touching the caller's*sql.DBconnection-pool configuration. The package doc's "Concurrency" section spells out exactly what that mutex covers (calls through oneSequenceStoreinstance in one process) and what it doesn't (a second connection/process sharing the same file — configure SQLite'sbusy_timeoutfor that).refid.SequenceStorefor local dev and tests, in addition to being a real second backend.SequenceStore-named,refid/store/postgres-shapedmainonce both merge in order.Test plan
go build ./...,go vet ./...,golangci-lint runcleango test -race ./...— increment, overflow-freezes-counter, invalid-table-name-returns-error-not-panic, 50-goroutine no-duplicates, and a regression test provingNextfails promptly (not hangs) when another transaction on the same*sql.DBholds SQLite's write lockgo test -race ./...passes🤖 Generated with Claude Code