database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package database builds a tuned pgx connection pool and provides a transaction helper. The pool registers google/uuid so sqlc-generated code can scan UUID columns directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPool

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

NewPool parses the DSN, applies pool tuning, registers the UUID codec, and verifies connectivity before returning.

func WithinTx

func WithinTx(ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) error) (err error)

WithinTx runs fn inside a transaction, committing on success and rolling back on error or panic. A panic is re-raised after the rollback.

Types

type Config

type Config struct {
	URL               string
	MaxConns          int32
	MinConns          int32
	MaxConnLifetime   time.Duration
	MaxConnIdleTime   time.Duration
	HealthCheckPeriod time.Duration
	ConnectTimeout    time.Duration
}

Jump to

Keyboard shortcuts

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