pg

package
v1.10.21-0...-113a02c Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInTx = errors.New("already executing in existing db tx")
	ErrNotInTx     = errors.New("not executing in existing db tx")
)

Functions

func CheckNoRows

func CheckNoRows(inErr, outErr error) error

func CheckUniqueViolation

func CheckUniqueViolation(inErr, outErr error) error

func ExecuteInTx

func ExecuteInTx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, fn func(tx *sqlx.Tx) error) (err error)

ExecuteInTx is meant for DB store implementations to execute an operation within the scope of a DB transaction. This method is aware of ExecuteTxWithinCtx, and will dynamically decide when to use a new or existing transaction, as well as where the respnosibilty for commit/rollback calls lie.

func ExecuteRetryable

func ExecuteRetryable(fn func() error) error

ExecuteRetryable Retry functions that perform non-transactional database operations.

func ExecuteTxWithinCtx

func ExecuteTxWithinCtx(ctx context.Context, db *sqlx.DB, isolation sql.IsolationLevel, fn func(context.Context) error) error

ExecuteTxWithinCtx executes a DB transaction that's scoped to a call to fn. The transaction is passed along with the context. Once fn is complete, commit/rollback is called based on whether an error is returned.

func IsNoRows

func IsNoRows(err error) bool

func IsUniqueViolation

func IsUniqueViolation(err error) bool

func NewWithAwsIam

func NewWithAwsIam(username, hostname, port, dbname string, config aws.Config) (*sql.DB, error)

Get a DB connection pool using AWS IAM credentials

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.Connecting.Go.html

func NewWithUsernameAndPassword

func NewWithUsernameAndPassword(username, password, hostname, port, dbname string) (*sql.DB, error)

Get a DB connection pool using username/password credentials

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.Connecting.Go.html

Types

type Config

type Config struct {
	User               string
	Host               string
	Password           string
	Port               int
	DbName             string
	MaxOpenConnections int
	MaxIdleConnections int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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