pgxpoolv5

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPingTimeout = 15 * time.Second

Variables

This section is empty.

Functions

func Query

func Query[T any](ctx context.Context, db *DB, query string,
	pointers func(*T) []interface{}, args ...any) ([]T, error)

Query is a generic query helper with context.

Types

type DB

type DB struct {
	*dbx.DB[*pgxpool.Pool]
	// contains filtered or unexported fields
}

func NewDB

func NewDB(dsns []string, options ...Option) (*DB, error)

func (*DB) CopyFrom

func (db *DB) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

func (*DB) DoTx

func (db *DB) DoTx(f func(db dbx.DBxer[*pgxpool.Pool, pgx.Tx, pgx.TxOptions]) error, opts pgx.TxOptions) error

func (*DB) DoTxContext

func (db *DB) DoTxContext(
	ctx context.Context,
	f func(ctx context.Context, db dbx.DBxer[*pgxpool.Pool, pgx.Tx, pgx.TxOptions]) error,
	opts pgx.TxOptions) error

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)

func (*DB) Prepare

func (db *DB) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)

func (*DB) Query

func (db *DB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

func (*DB) SendBatch

func (db *DB) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

func (*DB) Tx

func (db *DB) Tx() (pgx.Tx, error)

func (*DB) WithCtx added in v0.0.2

func (db *DB) WithCtx(ctx context.Context) *DB

func (*DB) WithDefaultNodeStrategy added in v0.0.3

func (db *DB) WithDefaultNodeStrategy(strategy dbx.GetNodeStragegy) *DB

func (*DB) WithNodeWaitTimeout added in v0.0.3

func (db *DB) WithNodeWaitTimeout(timeout time.Duration) *DB

func (*DB) WithReadFromNodeStrategy added in v0.0.3

func (db *DB) WithReadFromNodeStrategy(strategy dbx.GetNodeStragegy) *DB

func (*DB) WithWriteToNodeStrategy added in v0.0.3

func (db *DB) WithWriteToNodeStrategy(strategy dbx.GetNodeStragegy) *DB

type Option

type Option func(*DB)

func WithGenericOptions

func WithGenericOptions(options ...dbx.Option[*pgxpool.Pool]) Option

func WithNodeChecker added in v0.0.7

func WithNodeChecker(nodeChecker cluster.NodeChecker[*pgxpool.Pool]) Option

func WithPoolCloser added in v0.0.7

func WithPoolCloser(poolCloser cluster.ConnCloser[*pgxpool.Pool]) Option

func WithPoolOpener

func WithPoolOpener(poolOpener PoolOpener) Option

type PoolOpener

type PoolOpener func(ctx context.Context, dsn string) (*pgxpool.Pool, error)

func CustomPoolOpener added in v0.0.9

func CustomPoolOpener(poolOpener PoolOpener, callbacks ...func(*pgxpool.Pool) error) PoolOpener

func DefaultPoolOpener

func DefaultPoolOpener() PoolOpener

Jump to

Keyboard shortcuts

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