exec

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 5 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 exec defines the seam between ant and database/sql.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	SQL      string
	Err      error
	Detailed bool
}

Error is a failed statement. Its message is the driver's own, unless Detailed is set, so SQL only reaches logs and users on request.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the driver's error.

type Executor

type Executor interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

Executor is the part of *sql.DB, *sql.Tx, and *sql.Conn that ant uses to run statements.

func Wrap

func Wrap(e Executor, interceptors []Interceptor, replica, detailed bool) Executor

Wrap returns e with error context, and interceptors if there are any.

type Interceptor

type Interceptor interface {
	Before(ctx context.Context, s *Statement) (context.Context, error)
	After(ctx context.Context, s *Statement, o Outcome)
}

Interceptor observes statements. Before can replace the context, and stop the statement by returning an error.

type Observed

type Observed struct {
	Executor
	Interceptors []Interceptor
	Replica      bool
	Detailed     bool
}

Observed runs statements through interceptors.

func (*Observed) ExecContext

func (o *Observed) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext implements Executor.

func (*Observed) QueryContext

func (o *Observed) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext implements Executor.

type Outcome

type Outcome struct {
	Duration time.Duration
	Err      error
}

Outcome is what happened to a statement.

type Plain

type Plain struct {
	Executor
	Detailed bool
}

Plain runs statements with no interceptors, and records which one failed.

func (*Plain) ExecContext

func (p *Plain) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext implements Executor.

func (*Plain) QueryContext

func (p *Plain) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext implements Executor.

type Statement

type Statement struct {
	SQL     string
	Args    []any
	Replica bool // read from a replica
}

Statement is one SQL statement on its way to the database.

Jump to

Keyboard shortcuts

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