dbutils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCouldNotAcquireLock = errors.New("could not acquire database lock")
)

Functions

func NewPGXLocks

func NewPGXLocks(ctx context.Context, db PGXInterface, lockIDs ...string) error

NewPGXLocks acquire pg_advisory_xact_lock locks for each lockID given. Duplicates in lockIDs getting filtered out.

func Transaction

func Transaction(
	ctx context.Context,
	db *pgx.Conn,
	do func(tx pgx.Tx) error,
	options ...func(*Options),
) error

Transaction opens a transaction with the possibility of special options that are bound to it. The code that runs in the do parameter function is fully transactional with all its options.

func WithAdvisoryLock

func WithAdvisoryLock(key string) func(*Options)

WithAdvisoryLock this option configures advisory locks to the given transaction.

func WithLockTimeout

func WithLockTimeout(timeoutSeconds uint8) func(*Options)

WithLockTimeout this option configures the local lock timeout.

Types

type AcquiredLocks

type AcquiredLocks struct {
	IDs []string
}

type Options

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

type PGXInterface

type PGXInterface interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
}

Jump to

Keyboard shortcuts

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