store

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDataDir = ".agentprov"
View Source
const SchemaVersion = 20

Variables

This section is empty.

Functions

func EnsureSchema

func EnsureSchema(db *sql.DB) error

func ExecRetry added in v0.10.0

func ExecRetry(ctx context.Context, db *sql.DB, query string, args ...any) (sql.Result, error)

func IsBusy added in v0.10.0

func IsBusy(err error) bool

IsBusy includes extended SQLITE_BUSY/SQLITE_LOCKED result codes. Other storage failures must retain their original error and are not retried.

func Open

func Open(paths Paths) (*sql.DB, error)

func RetryBusy added in v0.10.0

func RetryBusy(ctx context.Context, operation func() error) error

RetryBusy retries an atomic statement or a transaction that rolls back on failure. The connection busy timeout bounds each attempt; the caller's context can end the wait sooner. Never wrap non-idempotent external work.

func WithTx added in v0.10.0

func WithTx(ctx context.Context, db *sql.DB, apply func(*sql.Tx) error) (err error)

WithTx pins the connection until commit or rollback has completed. The callback must not commit or roll back the transaction itself.

SQLite can leave a transaction active after a failed COMMIT, while sql.Tx is already done. Discard that connection before it can return to the pool.

func WithWriteTx added in v0.10.0

func WithWriteTx(ctx context.Context, db *sql.DB, apply func(*sql.Tx) error) error

WithWriteTx reserves the SQLite writer before the callback reads a snapshot. A deferred read transaction cannot upgrade a stale WAL snapshot, even with a busy handler. This zero-row write changes no schema metadata and lets the busy handler wait before any application reads or external writes occur. The database must already have an initialized schema.

Types

type Paths

type Paths struct {
	Root       string
	DB         string
	Workspaces string
	Snapshots  string
	Templates  string
	Artifacts  string
	Provenance string
	Secrets    string
	Logs       string
	Spool      string
}

func Init

func Init(root string) (Paths, error)

func ResolvePaths

func ResolvePaths(root string) Paths

Jump to

Keyboard shortcuts

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