sqlite

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAt added in v0.8.0

func CreateAt(path string, version int, setup string) error

CreateAt writes a database at path as an older dockhand left it, at schema version, with setup run in it after: for tests of what a newer build does with one, a migration it asks a person about among them.

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
	// 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
}

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

func Open(ctx context.Context, path string, options Options) (*Store, error)

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) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) Migration

func (s *Store) Migration() *Migration

Migration is the migration Open made; nil where it made none.

func (*Store) Register

func (s *Store) Register(ctx context.Context, commonDir string) (model.RepositoryID, error)

Register records the repository for a Git common directory.

func (*Store) Repositories added in v0.5.0

func (s *Store) Repositories(ctx context.Context) ([]string, error)

Repositories lists the registered Git common directories, oldest first.

func (*Store) Update

func (s *Store) Update(ctx context.Context, repository model.RepositoryID, fn func(store.Tx) error) error

Update runs fn in a write transaction bound to the repository.

func (*Store) View

func (s *Store) View(ctx context.Context, repository model.RepositoryID, fn func(store.Reader) error) error

View runs fn in a read transaction bound to the repository.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL