db

package
v0.0.0-...-258f5cf Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPool

func NewPool(ctx context.Context, conf PoolConfig) (*pgxpool.Pool, error)

Types

type PgTxManager

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

func NewPgTxManager

func NewPgTxManager(poolMaster *pgxpool.Pool) *PgTxManager

func (*PgTxManager) Close

func (m *PgTxManager) Close()

func (*PgTxManager) Conn

func (m *PgTxManager) Conn() Transaction

func (*PgTxManager) RunMaster

func (m *PgTxManager) RunMaster(ctx context.Context, fn func(ctxTx context.Context, tx Transaction) error) error

type PoolConfig

type PoolConfig struct {
	DSN string
}

type Transaction

type Transaction interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type TxManager

type TxManager interface {
	RunMaster(ctx context.Context, fn func(ctxTx context.Context, tx Transaction) error) error
	RunReplica(ctx context.Context, fn func(ctxTx context.Context, tx Transaction) error) error
	RunRepeatableRead(ctx context.Context, fn func(ctxTx context.Context, tx Transaction) error) error
}

Jump to

Keyboard shortcuts

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