Documentation
¶
Index ¶
- type SqlDB
- func (s *SqlDB) BeginTx(ctx context.Context) (*SqlTx, error)
- func (s *SqlDB) Close() error
- func (s *SqlDB) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (s *SqlDB) Ping(ctx context.Context, timeout time.Duration) error
- func (s *SqlDB) PoolStat() (idle, used int32, ok bool)
- func (s *SqlDB) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (s *SqlDB) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- type SqlTx
- func (t *SqlTx) BeginTx(ctx context.Context) (*SqlTx, error)
- func (t *SqlTx) Commit(ctx context.Context) error
- func (t *SqlTx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (t *SqlTx) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (t *SqlTx) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (t *SqlTx) Rollback(ctx context.Context) error
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: PoolStat (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 (*SqlDB) PoolStat ¶ added in v1.37.0
PoolStat returns idle/acquired connection counts as primitives (so callers don't need to import pgxpool) and, unlike the other accessors, 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.
type SqlTx ¶
type SqlTx struct {
// contains filtered or unexported fields
}
func (*SqlTx) BeginTx ¶ added in v1.10.0
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.