Versions in this module Expand all Collapse all v0 v0.7.0 Nov 4, 2026 v0.6.0 Nov 3, 2026 v0.5.3 Nov 3, 2026 v0.5.2 Nov 2, 2026 v0.5.1 Nov 2, 2026 v0.5.0 Nov 2, 2026 v0.4.0 Nov 1, 2026 v0.3.3 Nov 1, 2026 v0.3.2 Oct 31, 2026 v0.3.1 Oct 31, 2026 v0.3.0 Oct 31, 2026 v0.2.0 Oct 30, 2026 v0.1.0 Oct 27, 2026 Changes in this version + const MaxRetryAttempts + func FieldEncryption(row Row) (context.Context, *encryption.Keyring, error) + func ForEach[T any](ctx context.Context, executor Executor, statement string, arguments []any, ...) (err error) + func FoundryObservers(writer any, seal sqlowner.ObserverSeal) (lifecycle.Observers, bool) + func FoundryStatementUnknown(seal sqlowner.OutcomeSeal, operation string, cause error) error + func Module(name foundation.ProviderID, key foundation.Key[*DB], ...) foundation.Module + func NewError(operation string, code Code) error + func RegisterObserver[M, H any](r *foundation.Registrar, pool foundation.Key[*DB], ...) error + func Retry(ctx context.Context, transactor Transactor, policy RetryPolicy, ...) error + func ScanOne(ctx context.Context, executor Executor, statement string, arguments []any, ...) (err error) + func StickyReads(ctx context.Context) context.Context + func StickyReadsHandler(next http.Handler) http.Handler + type Adapter struct + Classify func(error) Detail + Connector driver.Connector + type Code string + const AfterCommitFailed + const Busy + const Canceled + const CheckViolation + const Closed + const CommitUnknown + const DataException + const DatetimeFieldOverflow + const DeadlineExceeded + const Deadlock + const DivisionByZero + const ExclusionViolation + const ForeignKeyViolation + const IdleInTransactionTimeout + const InsufficientResources + const InvalidDatetimeFormat + const InvalidTextRepresentation + const LockNotAvailable + const NotFound + const NotNullViolation + const NotReady + const NumericValueOutOfRange + const ObjectInUse + const QueryCanceled + const QueryFailed + const ReadOnlyTransaction + const RestrictViolation + const SerializationFailure + const StringDataRightTruncation + const TooManyRows + const Unavailable + const UniqueViolation + func (c Code) Error() string + type Connection struct + Name ConnectionName + Value *DB + type ConnectionName string + func (n ConnectionName) Validate() error + type Connections struct + func NewConnections(selected ConnectionName, entries ...Connection) (*Connections, error) + func (r *Connections) Connection(name ConnectionName) (*DB, error) + func (r *Connections) Default() (*DB, error) + func (r *Connections) DefaultName() ConnectionName + func (r *Connections) Names() []ConnectionName + type DB struct + func Open(ctx context.Context, adapter Adapter, config PoolConfig, options ...Option) (*DB, error) + func Prepare(adapter Adapter, config PoolConfig, options ...Option) (*DB, error) + func (db *DB) BindObservers(set lifecycle.Observers) error + func (db *DB) Clock() clock.Clock + func (db *DB) Close(ctx context.Context) error + func (db *DB) Done() <-chan struct{} + func (db *DB) Encryption() *encryption.Keyring + func (db *DB) Exec(ctx context.Context, statement string, arguments ...any) (result Result, err error) + func (db *DB) FoundryAutocommitQuery(seal sqlowner.AutocommitSeal, ctx context.Context, statement string, ...) (*Rows, error) + func (db *DB) FoundryObservers(seal sqlowner.ObserverSeal) (set lifecycle.Observers, known bool) + func (db *DB) HasReadPool() bool + func (db *DB) Health(ctx context.Context) []PoolHealth + func (db *DB) Observers() lifecycle.Observers + func (db *DB) Ping(ctx context.Context) (err error) + func (db *DB) PingPrimary(ctx context.Context) error + func (db *DB) PingRead(ctx context.Context) error + func (db *DB) Primary() PrimaryExecutor + func (db *DB) Query(ctx context.Context, statement string, arguments ...any) (*Rows, error) + func (db *DB) QueryRead(ctx context.Context, statement string, arguments ...any) (*Rows, error) + func (db *DB) ReadinessProbes(primary, read health.ProbeID) []health.Probe + func (db *DB) RoutingStats() RoutingStats + func (db *DB) Session(ctx context.Context, fn func(*Session) error) (err error) + func (db *DB) Start(ctx context.Context) error + func (db *DB) Stats() Stats + func (db *DB) Transaction(ctx context.Context, fn func(*Tx) error, options ...TxOptions) (err error) + type Detail struct + Code Code + CommitRejected bool + Constraint string + SQLState string + Schema string + StatementRejected bool + Table string + type EncryptedRow interface + FieldEncryption func() (context.Context, *encryption.Keyring) + type Error struct + func (e *Error) Code() Code + func (e *Error) Constraint() string + func (e *Error) Error() string + func (e *Error) FoundryDiagnostic(seal errordiag.Seal) []fault.Attribute + func (e *Error) GoString() string + func (e *Error) Is(target error) bool + func (e *Error) Outcome() Outcome + func (e *Error) SQLState() string + func (e *Error) Schema() string + func (e *Error) Table() string + func (e *Error) Unwrap() error + type Executor interface + Exec func(context.Context, string, ...any) (Result, error) + Query func(context.Context, string, ...any) (*Rows, error) + type Isolation uint8 + const DefaultIsolation + const ReadCommitted + const RepeatableRead + const Serializable + type JSONKind string + const JSONArray + const JSONBoolean + const JSONNull + const JSONNumber + const JSONObject + const JSONString + func (k JSONKind) Validate() error + type Option func(*poolSettings) error + func WithClock(source clock.Clock) Option + func WithConnectionLimit(maxConnections int) Option + func WithEncryption(keys *encryption.Keyring) Option + func WithQueryObserver(observer QueryObserver) Option + func WithReadPool(adapter func() (Adapter, error), config PoolConfig, maxConnections int) Option + func WithSlowQueryLog(logger *slog.Logger, threshold time.Duration) Option + func WithSlowQueryThreshold(threshold time.Duration) Option + func WithStartupLog(logger *slog.Logger) Option + func WithStatementDetector(d *StatementDetector) Option + func WithStickyReads(window time.Duration) Option + type Outcome string + const Committed + const NoCommit + const RolledBack + const Unknown + const Unspecified + type PoolConfig struct + AcquireTimeout time.Duration + CommitTimeout time.Duration + ConnectTimeout time.Duration + MaxIdle int + MaxIdleTime time.Duration + MaxLifetime time.Duration + MaxOpen int + StartupTimeout time.Duration + func DefaultPoolConfig() PoolConfig + func (c PoolConfig) Validate() error + type PoolHealth struct + Error error + Role PoolRole + type PoolRole string + const PrimaryPool + const ReadPool + type PoolStats struct + Idle int + InUse int + MaxIdleClosed int64 + MaxIdleTimeClosed int64 + MaxLifetimeClosed int64 + MaxOpen int + Open int + Role PoolRole + WaitCount int64 + WaitDuration time.Duration + type PrimaryExecutor struct + func (p PrimaryExecutor) Clock() clock.Clock + func (p PrimaryExecutor) Exec(ctx context.Context, statement string, arguments ...any) (Result, error) + func (p PrimaryExecutor) FoundryAutocommitQuery(seal sqlowner.AutocommitSeal, ctx context.Context, statement string, ...) (*Rows, error) + func (p PrimaryExecutor) FoundryObservers(seal sqlowner.ObserverSeal) (lifecycle.Observers, bool) + func (p PrimaryExecutor) Query(ctx context.Context, statement string, arguments ...any) (*Rows, error) + func (p PrimaryExecutor) Transaction(ctx context.Context, fn func(*Tx) error, options ...TxOptions) error + type QueryEvent struct + Code Code + Duration time.Duration + Operation string + PoolWait time.Duration + Role PoolRole + Rows int64 + SQLState string + Statement string + type QueryObserver func(context.Context, QueryEvent) + type ReadRouter interface + QueryRead func(context.Context, string, ...any) (*Rows, error) + type Result struct + RowsAffected int64 + type RetryPolicy struct + Attempts int + InitialDelay time.Duration + MaxDelay time.Duration + func DefaultRetryPolicy() RetryPolicy + func (p RetryPolicy) Validate() error + type RoutingStats struct + MaxConnections int + Primary PoolStats + Read value.Optional[PoolStats] + type Row interface + Scan func(...any) error + type Rows struct + func ReadQuery(ctx context.Context, executor Executor, statement string, arguments ...any) (*Rows, error) + func (r *Rows) Close() error + func (r *Rows) Columns() ([]string, error) + func (r *Rows) Err() error + func (r *Rows) FieldEncryption() (context.Context, *encryption.Keyring) + func (r *Rows) FoundryCollect(seal sqlowner.CollectionSeal, ctx context.Context, scan func(Row) error) (count int, err error) + func (r *Rows) Next() bool + func (r *Rows) Observers() lifecycle.Observers + func (r *Rows) Scan(destinations ...any) error + func (r *Rows) WithObserverScope(ctx context.Context, fn func(context.Context) error) (err error) + type Session struct + func (s *Session) Clock() clock.Clock + func (s *Session) Discard() + func (s *Session) Encryption() *encryption.Keyring + func (s *Session) Exec(ctx context.Context, statement string, arguments ...any) (Result, error) + func (s *Session) FoundryObservers(seal sqlowner.ObserverSeal) (lifecycle.Observers, bool) + func (s *Session) Observers() lifecycle.Observers + func (s *Session) Query(ctx context.Context, statement string, arguments ...any) (*Rows, error) + func (s *Session) Transaction(ctx context.Context, fn func(*Tx) error, options ...TxOptions) error + type StatementDetector struct + func NewStatementDetector(c StatementDetectorConfig) (*StatementDetector, error) + func (*StatementDetector) GoString() string + func (*StatementDetector) String() string + func (d *StatementDetector) Begin(ctx context.Context) (context.Context, *StatementScope) + func (d *StatementDetector) Observe(ctx context.Context, event QueryEvent) + type StatementDetectorConfig struct + MaxShapes int + Threshold int + func DefaultStatementDetectorConfig() StatementDetectorConfig + type StatementReport struct + CallSiteOverflow bool + Overflow bool + Violations []StatementViolation + type StatementScope struct + func (s *StatementScope) Report() StatementReport + type StatementViolation struct + CallSiteOverflow bool + CallSites []string + Count int + Shape string + Threshold int + type Stats struct + Closing bool + Idle int + InUse int + Open int + Owners int + Ready bool + WaitCount int64 + WaitDuration time.Duration + type Transactor interface + Transaction func(context.Context, func(*Tx) error, ...TxOptions) error + type Tx struct + func (tx *Tx) AfterCommit(fn func(context.Context) error) error + func (tx *Tx) BelongsTo(db *DB) bool + func (tx *Tx) Clock() clock.Clock + func (tx *Tx) Encryption() *encryption.Keyring + func (tx *Tx) Exec(ctx context.Context, statement string, arguments ...any) (result Result, err error) + func (tx *Tx) FoundryObservers(seal sqlowner.ObserverSeal) (lifecycle.Observers, bool) + func (tx *Tx) Observers() lifecycle.Observers + func (tx *Tx) Query(ctx context.Context, statement string, arguments ...any) (*Rows, error) + func (tx *Tx) Savepoint(ctx context.Context, fn func(*Tx) error) error + func (tx *Tx) SharesTransaction(other *Tx) bool + func (tx *Tx) State() TxState + func (tx *Tx) Transaction(ctx context.Context, fn func(*Tx) error, options ...TxOptions) error + type TxOptions struct + Isolation Isolation + ReadOnly bool + type TxState string + const TxActive + const TxCommitted + const TxFinishing + const TxReleased + const TxRolledBack + const TxUnknown