Documentation
¶
Overview ¶
Package sqlite implements the store contract on one SQLite database, dockhand v3's ~/.dockhand/dockhand.db.
The database is opened in WAL mode with foreign keys on and full sync, through to the disk on macOS, and its planner's statistics kept. A write transaction begins IMMEDIATE, so writers queue on SQLite's lock instead of failing midway, and a commit whose outcome is unknown says so with store.ErrUncertain. The schema carries the rules it can check by itself: valid states, unique run numbers and snapshot numbers, final checkpoints, and lease generations that never decrease.
Index ¶
- Variables
- func Backup(ctx context.Context, path, into string, options Options) (store.Backup, error)
- func CreateAt(path string, version int, setup string) error
- type Migration
- type Options
- type Store
- func (s *Store) Close() error
- func (s *Store) Migration() *Migration
- func (s *Store) Register(ctx context.Context, commonDir string) (model.RepositoryID, error)
- func (s *Store) Repositories(ctx context.Context) ([]string, error)
- func (s *Store) Update(ctx context.Context, repository model.RepositoryID, fn func(store.Tx) error) error
- func (s *Store) View(ctx context.Context, repository model.RepositoryID, ...) error
Constants ¶
This section is empty.
Variables ¶
var ErrBackupExists = errors.New("a file is already there")
ErrBackupExists is a backup's refusal of a file already there: a backup never replaces one.
Functions ¶
func Backup ¶ added in v0.9.0
Backup copies the dockhand database at path to into, whole or not at all, the way a migration keeps its copy (copyWhole): a consistent copy while other processes write, since a reader doesn't block writers in WAL mode, compacted, a plain SQLite file with no -wal, readable only by its owner. It opens the file alone, as any SQLite reader does: no migration, no session, and no record written, so a build backs up a database of an older schema before it migrates it, and one of a newer schema it can't otherwise open. A file that isn't a dockhand v3 database is refused by name, as Open refuses one, and so is an into that exists. into's directory is made where it's missing, as the database's own is.
Types ¶
type Migration ¶
type Migration struct {
From, To int
Copy string
// Release is the release that last opened the database, where this
// build isn't one and migrated it as MigrateRelease let it: that
// release can't open it after.
Release string
}
Migration is a schema migration Open made, and where the database's form before it is kept: a build older than the migration can't open the database after it, and can open the copy.
type Options ¶
type Options struct {
BusyTimeout time.Duration
OperationTimeout time.Duration
// MigrateUnderLive migrates the schema though dockhand processes that
// read the older one are working, a person's answer; otherwise such a
// migration is refused (store.LiveUnderMigrationError).
MigrateUnderLive bool
// Build is this build's version, as buildinfo.Info.String gives it, and
// MigrateRelease migrates a database a release last opened with a
// build that isn't one, a person's answer or a copy they named, which
// is otherwise refused (store.ReleaseUnderMigrationError).
Build string
MigrateRelease bool
// Default is the database being the default one, named neither by
// --db nor DOCKHAND_DB, and MigrateDevelopment a person's consent, by
// its own flag, to this build migrating it where it isn't a release
// (store.DevelopmentMigrationError, #281).
Default, MigrateDevelopment bool
// LiveWithin is how recent a heartbeat says a process is working,
// coord.DefaultHungAfter, which the engine gives; where it's zero,
// every session not ended is working.
LiveWithin time.Duration
// Heartbeat is how often a working process records its heartbeat,
// coord's, which the engine gives. Where it's set, a migration
// refused for live processes counts only those whose heartbeat moves
// in this file while it waits three beats: a copy of a database
// carries its sessions, fresh, and the processes behind them work on
// the original (field testing's .backup copy, 2026-10-29).
Heartbeat time.Duration
// Quiet lists the other dockhand processes on this Mac, which the
// engine gives as procid.Named("dockhand"): a migration to the
// publication record's schema waits until there are none
// (store.QuietUnderMigrationError). Nil checks nothing, as a test's
// store does.
Quiet func() ([]int, error)
}
Options tunes how the database is opened.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a dockhand v3 database.
func Open ¶
Open opens the database at path, creating it and its directory when absent, and refuses a file that is not a dockhand v3 database.
func (*Store) Repositories ¶ added in v0.5.0
Repositories lists the registered Git common directories, oldest first.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sqlitetest gives tests a new dockhand database without each running every migration: a fresh database takes the schema's whole history, about fifty migrations, each in its own transaction synced to the disk, and hundreds of tests open one.
|
Package sqlitetest gives tests a new dockhand database without each running every migration: a fresh database takes the schema's whole history, about fifty migrations, each in its own transaction synced to the disk, and hundreds of tests open one. |