Documentation
¶
Index ¶
- func IsWithinTransaction(ctx context.Context) bool
- func NewFakeTransactor(db *pgx.Conn) (FakeTransactor, DBGetter)
- func NewFakeTransactorFromPool(db *pgxpool.Pool) (FakeTransactor, DBGetter)
- func NewTransactor(db *pgx.Conn) (*Transactor, DBGetter)
- func NewTransactorFromPool(pool *pgxpool.Pool) (*Transactor, DBGetter)
- type DB
- type DBGetter
- type FakeTransactor
- type Transactor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWithinTransaction ¶
func NewFakeTransactor ¶
func NewFakeTransactor(db *pgx.Conn) (FakeTransactor, DBGetter)
NewFakeTransactor initializes a Transactor and DBGetter that do nothing: - the Transactor just executes its callback and returns the error, - the DBGetter just returns the DB handler. They can be used in tests where the transaction system itself doesn't need to be tested.
func NewFakeTransactorFromPool ¶
func NewFakeTransactorFromPool(db *pgxpool.Pool) (FakeTransactor, DBGetter)
NewFakeTransactorFromPool initializes a Transactor and DBGetter that do nothing: - the Transactor just executes its callback and returns the error, - the DBGetter just returns the DB handler. They can be used in tests where the transaction system itself doesn't need to be tested.
func NewTransactor ¶
func NewTransactor(db *pgx.Conn) (*Transactor, DBGetter)
func NewTransactorFromPool ¶
func NewTransactorFromPool(pool *pgxpool.Pool) (*Transactor, DBGetter)
Types ¶
type DB ¶
type DB interface { Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults }
DB is the common interface between *pgx.Conn, *pgx.Tx, *pgxpool.Conn, *pgxpool.Pool and *pgxpool.Tx.
type DBGetter ¶
DBGetter is used to get the current DB handler from the context. It returns the current transaction if there is one, otherwise it will return the original DB.
type Transactor ¶
type Transactor struct {
// contains filtered or unexported fields
}