Documentation
¶
Overview ¶
Package sqlite implements store.Store on SQLite via a pure-Go driver.
Two design points are deliberate and load-bearing:
- The driver is modernc.org/sqlite (no cgo), because "one static binary, no separate service" is a stated property of the product. A cgo driver would trade that away for marginal speed.
- There are two connection pools. Writes go through a pool capped at ONE connection, which serializes them at the pool and removes the `SQLITE_BUSY` / "database is locked" failure mode entirely once the executor runs multiple workers. Reads use a normal pool and run concurrently under WAL.
Index ¶
- func ExpectedSchemaVersion() (int, error)
- type DB
- func (d *DB) Close() error
- func (d *DB) Migrate(ctx context.Context) error
- func (d *DB) Path() string
- func (d *DB) Read(ctx context.Context, fn func(context.Context, store.Queries) error) error
- func (d *DB) SchemaVersion(ctx context.Context) (int, error)
- func (d *DB) WithTx(ctx context.Context, fn func(context.Context, store.Tx) error) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpectedSchemaVersion ¶
ExpectedSchemaVersion is the highest migration this binary ships.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the SQLite-backed store.
func Open ¶
Open prepares the database at path, creating it if needed. Use ":memory:" for tests; that mode collapses to a single shared connection because an in-memory database is per-connection.
func (*DB) Migrate ¶
Migrate applies pending migrations. Each runs in its own transaction and records its version, so a partially-applied set is resumable rather than requiring a manual repair.
func (*DB) SchemaVersion ¶
SchemaVersion reports the highest applied migration, or 0 on a fresh database. It reads through the read pool, so a read-only command can check the schema without taking a write lock — which matters because the daemon may hold the writer while the CLI runs.
type Options ¶
type Options struct {
// ReadConns caps the read pool. Defaults to 8.
ReadConns int
// BusyTimeout is how long a statement waits on a lock before erroring.
// Defaults to 5s. With a single-writer pool this should never be hit from
// inside one process; it matters when a second process (the CLI) attaches.
BusyTimeout time.Duration
}
Options configures the store. The zero value is usable.