postrgres

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = types.Module{
	{CreateFunc: NewPostgresConfig},
	{CreateFunc: NewPostgres},
	{CreateFunc: NewSQLConnector},
	{CreateFunc: NewGoQuConnector},
	{CreateFunc: NewPGXPoolConn},
	{CreateFunc: NewPGXPool},
}

Functions

func NewGoQuConnector

func NewGoQuConnector(
	poolDB map[string]*sqlx.DB,
	logger *zap.Logger,
	cfg *config.Config,
) map[string]connectors.DBConnector[*goqu.Database, *goqu.TxDatabase]

func NewPGXPool added in v1.0.7

func NewPGXPool(
	ctx context.Context,
	config PostgresConfig,
) (map[string]*pgxpool.Pool, error)

func NewPGXPoolConn added in v1.0.7

func NewPGXPoolConn(
	ctx context.Context,
	pgxPool map[string]*pgxpool.Pool,
	logger *zap.Logger,
	cfg *config.Config,
) (map[string]connectors.DBConnector[dbtypes.PgxConn, dbtypes.PgxTx], error)

func NewPostgres

func NewPostgres(config PostgresConfig) (map[string]*sqlx.DB, error)

func NewSQLConnector

func NewSQLConnector(
	poolDB map[string]*sqlx.DB,
	logger *zap.Logger,
	cfg *config.Config,
) map[string]connectors.DBConnector[*sqlx.DB, *sqlx.Tx]

Types

type DBConfig added in v1.0.1

type DBConfig struct {
	DSN  string
	Name string
	// Type pgx|sqlx
	Type               string
	MaxOpenConnections int
	MaxIdleConnections int
	ConnMaxLifetime    time.Duration
}

type GoQuConn

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

func (*GoQuConn) CallContext

func (s *GoQuConn) CallContext(
	ctx context.Context,
	queryName string,
	callFunc func(ctx context.Context, gq *goqu.Database) error,
) error

func (*GoQuConn) CallTransaction

func (s *GoQuConn) CallTransaction(
	ctx context.Context,
	txName string,
	callFunc func(ctx context.Context, gqx *goqu.TxDatabase) error,
) error

type PGXPoolConn added in v1.0.7

type PGXPoolConn struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

func (*PGXPoolConn) CallContext added in v1.0.7

func (c *PGXPoolConn) CallContext(
	ctx context.Context,
	queryName string,
	callFunc func(ctx context.Context, db dbtypes.PgxConn) error,
) error

func (*PGXPoolConn) CallTransaction added in v1.0.7

func (c *PGXPoolConn) CallTransaction(
	ctx context.Context,
	txName string,
	callFunc func(ctx context.Context, tx dbtypes.PgxTx) error,
) error

func (*PGXPoolConn) Get added in v1.0.7

func (c *PGXPoolConn) Get(ctx context.Context, dst any, query string, args ...any) error

func (*PGXPoolConn) Select added in v1.0.7

func (c *PGXPoolConn) Select(ctx context.Context, dst any, query string, args ...any) error

func (*PGXPoolConn) Stats added in v1.0.7

func (c *PGXPoolConn) Stats() sql.DBStats

type PostgresConfig

type PostgresConfig struct {
	Configs []DBConfig
}

func NewPostgresConfig

func NewPostgresConfig(cfg *config.Config) PostgresConfig

type SQLConn

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

func (*SQLConn) CallContext

func (s *SQLConn) CallContext(
	ctx context.Context,
	queryName string,
	callFunc func(ctx context.Context, db *sqlx.DB) error,
) error

func (*SQLConn) CallTransaction

func (s *SQLConn) CallTransaction(
	ctx context.Context,
	txName string,
	callFunc func(ctx context.Context, tx *sqlx.Tx) error,
) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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