Documentation
¶
Overview ¶
Package sqlcompletion shares the transactional completion invariant between SQL backends. Drivers supply only transaction and placeholder adapters.
Index ¶
- type Driver
- func (d Driver) BeginRunAttempt(ctx context.Context, runID string, generation int64) (bool, error)
- func (d Driver) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
- func (d Driver) CompleteRunInTx(ctx context.Context, tx Tx, c *state.RunCompletion) (state.CompletionResult, error)
- func (d Driver) DeleteBoundOpaqueCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, checkpointID string) error
- func (d Driver) LockRunCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error
- func (d Driver) LockThread(ctx context.Context, tx Tx, threadID string) (models.ThreadStatus, error)
- func (d Driver) WithRunCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, mutate func(Tx) error) error
- func (d Driver) WithThread(ctx context.Context, threadID string, mutate func(Tx) error) error
- type Row
- type Tx
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 ¶
DatabaseSQL adapts database/sql transactions. SQLite uses BEGIN IMMEDIATE so read/modify/write is serialized before the metadata is inspected.
func (Driver) BeginRunAttempt ¶
func (Driver) CompleteRun ¶
func (d Driver) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
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 (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 ¶
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 ¶
WrapSQLTransaction lets a store reuse the completion lock inside an existing database/sql transaction without opening another connection.
func WrapSQLiteConnection ¶
WrapSQLiteConnection adapts an already-open BEGIN IMMEDIATE transaction.