connection

package
v0.0.0-...-1d59f67 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDatabasePools

func CloseDatabasePools()

CloseDatabasePools: closes all open pools.

func GetDatabasePool

func GetDatabasePool(connectionString string) *pgxpool.Pool

GetDatabasePool: returns a database connection pool

Types

type PgxPool

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

func (*PgxPool) AcquireFunc

func (p *PgxPool) AcquireFunc(ctx context.Context, fn func(*pgxpool.Conn) error) error

AcquireFunc: returns a connection. Cleans up after execution

func (*PgxPool) BeginTxFunc

func (p *PgxPool) BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, fn func(pgx.Tx) error) error

BeginTxFunc: executes a database transation with automatic rollback on error, automatic commit when no error

type Pool

type Pool interface {
	AcquireFunc(ctx context.Context, fn func(*pgxpool.Conn) error) error
	BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, fn func(pgx.Tx) error) error
}

Pool: minimum interface for our usage. Facilitates testing abstraction.

func NewPgxPool

func NewPgxPool(connString string) Pool

Jump to

Keyboard shortcuts

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