Documentation
¶
Index ¶
- Constants
- func EnsureSchema(db *sql.DB) error
- func ExecRetry(ctx context.Context, db *sql.DB, query string, args ...any) (sql.Result, error)
- func IsBusy(err error) bool
- func Open(paths Paths) (*sql.DB, error)
- func RetryBusy(ctx context.Context, operation func() error) error
- func WithTx(ctx context.Context, db *sql.DB, apply func(*sql.Tx) error) (err error)
- func WithWriteTx(ctx context.Context, db *sql.DB, apply func(*sql.Tx) error) error
- type Paths
Constants ¶
const DefaultDataDir = ".agentprov"
const SchemaVersion = 20
Variables ¶
This section is empty.
Functions ¶
func EnsureSchema ¶
func IsBusy ¶ added in v0.10.0
IsBusy includes extended SQLITE_BUSY/SQLITE_LOCKED result codes. Other storage failures must retain their original error and are not retried.
func RetryBusy ¶ added in v0.10.0
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
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
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.