driver

package
v1.44.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqlDB

type SqlDB struct {
	// contains filtered or unexported fields
}

pool is an atomic.Pointer, not a plain field: PoolStats (below) is read by a Prometheus scrape goroutine whose lifecycle is independent of this DB's owning service, so a scrape can legitimately race a concurrent Close.

func NewPostgresDB

func NewPostgresDB(ctx context.Context, dataSource string) (*SqlDB, error)

func NewYugabyteDB

func NewYugabyteDB(ctx context.Context, dataSource string) (*SqlDB, error)

func (*SqlDB) BeginTx

func (s *SqlDB) BeginTx(ctx context.Context) (*SqlTx, error)

func (*SqlDB) Close

func (s *SqlDB) Close() error

func (*SqlDB) Exec

func (s *SqlDB) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)

func (*SqlDB) Ping

func (s *SqlDB) Ping(ctx context.Context, timeout time.Duration) error

func (*SqlDB) PoolStats added in v1.44.0

func (s *SqlDB) PoolStats() (dbstats.PoolStats, bool)

PoolStats reports pool state, the configured bounds and the acquisition counters. Unlike the other accessors it doesn't panic when the pool isn't set — ok is false instead, since a Prometheus scrape can legitimately land before connect or after Close.

func (*SqlDB) Query

func (s *SqlDB) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)

func (*SqlDB) QueryRow

func (s *SqlDB) QueryRow(ctx context.Context, query string, args ...any) pgx.Row

type SqlTx

type SqlTx struct {
	// contains filtered or unexported fields
}

func (*SqlTx) BeginTx added in v1.10.0

func (t *SqlTx) BeginTx(ctx context.Context) (*SqlTx, error)

BeginTx starts a nested transaction. pgx implements this with a SAVEPOINT, so Commit releases the savepoint and Rollback rolls back to it without affecting the enclosing transaction. Used by test helpers to give code that manages its own transactions full rollback isolation.

func (*SqlTx) Commit

func (t *SqlTx) Commit(ctx context.Context) error

func (*SqlTx) Exec added in v1.0.8

func (t *SqlTx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)

func (*SqlTx) Query

func (t *SqlTx) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)

func (*SqlTx) QueryRow added in v1.0.8

func (t *SqlTx) QueryRow(ctx context.Context, query string, args ...any) pgx.Row

func (*SqlTx) Rollback

func (t *SqlTx) Rollback(ctx context.Context) error

Jump to

Keyboard shortcuts

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