sqlcompletion

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 11 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 sqlcompletion shares the transactional completion invariant between SQL backends. Drivers supply only transaction and placeholder adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Begin          func(context.Context) (Tx, error)
	Dialect        string
	ValidateValues func(context.Context, Tx, []byte) error
}

func DatabaseSQL

func DatabaseSQL(db *sql.DB, dialect string) Driver

DatabaseSQL adapts database/sql transactions. SQLite uses BEGIN IMMEDIATE so read/modify/write is serialized before the metadata is inspected.

func (Driver) BeginRunAttempt

func (d Driver) BeginRunAttempt(ctx context.Context, runID string, generation int64) (bool, error)

func (Driver) CompleteRun

func (Driver) CompleteRunInTx

func (d Driver) CompleteRunInTx(ctx context.Context, tx Tx, c *state.RunCompletion) (state.CompletionResult, error)

CompleteRunInTx shares the completion writes with synchronous cached-run creation. The caller owns the transaction and must commit only after every admission, parent-ownership and completion operation succeeds.

func (Driver) DeleteBoundOpaqueCheckpoint

func (d Driver) DeleteBoundOpaqueCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, checkpointID string) error

func (Driver) LockRunCheckpoint

func (d Driver) LockRunCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error

LockRunCheckpoint uses the same run-row lock as attempt advancement and completion. The caller must keep tx open until its blob mutation commits.

func (Driver) LockThread

func (d Driver) LockThread(ctx context.Context, tx Tx, threadID string) (models.ThreadStatus, error)

LockThread binds a child mutation to the current parent owner. The row lock must be retained through the child write: a preceding API lookup cannot fence deletion and reuse of the same custom thread ID by a different tenant.

func (Driver) WithRunCheckpoint

func (d Driver) WithRunCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, mutate func(Tx) error) error

func (Driver) WithThread

func (d Driver) WithThread(ctx context.Context, threadID string, mutate func(Tx) error) error

type Row

type Row interface{ Scan(...interface{}) error }

type Tx

type Tx interface {
	Exec(context.Context, string, ...interface{}) error
	Row(context.Context, string, ...interface{}) Row
	Commit(context.Context) error
	Rollback(context.Context) error
}

func WrapSQLTransaction

func WrapSQLTransaction(tx *sql.Tx) Tx

WrapSQLTransaction lets a store reuse the completion lock inside an existing database/sql transaction without opening another connection.

func WrapSQLiteConnection

func WrapSQLiteConnection(conn *sql.Conn) Tx

WrapSQLiteConnection adapts an already-open BEGIN IMMEDIATE transaction.

Jump to

Keyboard shortcuts

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