Documentation
¶
Index ¶
- Variables
- func IsNotFound(err error) bool
- func MustRegisterDSN(s DSNScheme)
- type Config
- type ConnMaxIdleTime
- type ConnMaxLifetime
- type DB
- func (*DB) BuildConfig() (app.Materializer, error)
- func (db *DB) Close(_ context.Context) error
- func (db *DB) Exec(ctx context.Context, q Query, args ...any) error
- func (db *DB) ExecOne(ctx context.Context, q Query, args ...any) error
- func (db *DB) GetList(ctx context.Context, q Query, dest any, args ...any) error
- func (db *DB) GetOne(ctx context.Context, q Query, dest any, args ...any) error
- func (db *DB) Label() string
- func (db *DB) ProbeReady(ctx context.Context) error
- func (db *DB) WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error
- func (db *DB) WithinTransaction(ctx context.Context, fn func(ctx context.Context) error) error
- type DSN
- type DSNScheme
- type MaxIdleConns
- type MaxOpenConns
- type Meta
- type PoolConfig
- type Query
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoRows is returned when exactly one row was expected but none were found. ErrNoRows = sql.ErrNoRows // ErrMultipleRows is returned when exactly one row was expected but more were found. ErrMultipleRows = errors.New("connsql: expected exactly one row") )
Functions ¶
func MustRegisterDSN ¶ added in v0.2.0
func MustRegisterDSN(s DSNScheme)
MustRegisterDSN registers URL schemes for ParseDSN. Panics on empty scheme list, empty scheme/driver/dialect, or duplicate scheme.
Types ¶
type Config ¶
type Config struct {
Label common.Label
DSN DSN
Pool PoolConfig
}
Config is the conn-sql spec; ecfg fills before Build.
type ConnMaxIdleTime ¶
ConnMaxIdleTime is the maximum idle time before a connection is closed.
func (ConnMaxIdleTime) Usage ¶
func (ConnMaxIdleTime) Usage() string
func (ConnMaxIdleTime) Validate ¶
func (c ConnMaxIdleTime) Validate() error
type ConnMaxLifetime ¶
ConnMaxLifetime is the maximum lifetime of a connection.
func (ConnMaxLifetime) Usage ¶
func (ConnMaxLifetime) Usage() string
func (ConnMaxLifetime) Validate ¶
func (c ConnMaxLifetime) Validate() error
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the SQL database resource. Catalog field: *DB (Configurable).
func (*DB) BuildConfig ¶
func (*DB) BuildConfig() (app.Materializer, error)
BuildConfig returns the config spec for materialize.
func (*DB) ExecOne ¶
ExecOne runs a write and requires exactly one affected row. Always runs inside a transaction when not already in [WithTransaction]; rolls back on != 1.
func (*DB) GetOne ¶
GetOne loads exactly one row into dest (*T). Returns ErrNoRows or ErrMultipleRows when row count is not one.
func (*DB) ProbeReady ¶
ProbeReady reports database traffic readiness via Ping.
func (*DB) WithTransaction ¶
WithTransaction runs fn inside a SQL transaction. Nested calls reuse the outer transaction.
func (*DB) WithinTransaction ¶
WithinTransaction implements port.Transactor.
type DSNScheme ¶ added in v0.2.0
DSNScheme binds URL schemes to database/sql driver and sqlx dialect names. Register via driver shim packages (e.g. conn-sql/postgres) in init.
type MaxIdleConns ¶
type MaxIdleConns int
MaxIdleConns is the maximum number of idle connections.
func (MaxIdleConns) Usage ¶
func (MaxIdleConns) Usage() string
func (MaxIdleConns) Validate ¶
func (n MaxIdleConns) Validate() error
type MaxOpenConns ¶
type MaxOpenConns int
MaxOpenConns is the maximum number of open connections.
func (MaxOpenConns) Usage ¶
func (MaxOpenConns) Usage() string
func (MaxOpenConns) Validate ¶
func (n MaxOpenConns) Validate() error
type Meta ¶
type Meta struct {
Driver string // database/sql driver name registered by a driver shim
Dialect string // sqlx dialect
}
Meta describes how to open a parsed DSN.
type PoolConfig ¶
type PoolConfig struct {
MaxOpen MaxOpenConns
MaxIdle MaxIdleConns
MaxLifetime ConnMaxLifetime
MaxIdleTime ConnMaxIdleTime
}
PoolConfig tunes the Go sql.DB pool.