database

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvisoryTransactionLock added in v0.4.0

func AdvisoryTransactionLock(ctx context.Context, executor CommandExecutor, key string) error

AdvisoryTransactionLock obtains a transaction-scoped PostgreSQL advisory lock for a stable application key. The caller must execute it inside an active transaction; PostgreSQL releases the lock when that transaction ends.

func InTransaction added in v0.2.0

func InTransaction(
	ctx context.Context,
	pool *pgxpool.Pool,
	operation func(pgx.Tx) error,
) error

InTransaction runs operation in a transaction and automatically commits or rolls it back.

func NewPool

func NewPool(ctx context.Context, config Config) (*pgxpool.Pool, error)

NewPool creates a PostgreSQL connection pool and verifies that the database is available.

func OpenSQL

func OpenSQL(config Config) (*sql.DB, error)

OpenSQL creates a database/sql connection pool for migration tools.

Types

type CommandExecutor added in v0.4.0

type CommandExecutor interface {
	Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
}

CommandExecutor is implemented by pgx connections, pools and transactions.

type Config

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

Config contains PostgreSQL connection settings loaded from the ProcessModule runtime environment.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads PostgreSQL connection settings from environment variables and reads the password from a secret file.

Jump to

Keyboard shortcuts

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