postgres

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, dbCfg Config, database string, migrations fs.FS) (*pgxpool.Pool, error)

Connect bootstraps the database if needed, opens a pool, and applies *.up.sql migrations.

Types

type Config

type Config struct {
	Host               string
	Port               int
	User               string
	Password           string
	PreparedStatements bool
}

Config is PostgreSQL connection settings shared by Cotherapist Go services.

func Load

func Load(defaultUser string) (Config, error)

Load reads DATABASE_* env vars. defaultUser is used when DATABASE_USER is empty.

func (Config) ConnectionURL

func (d Config) ConnectionURL(database string) string

ConnectionURL builds a postgres:// DSN for the given database name.

func (Config) PoolConfig

func (d Config) PoolConfig(database string) (*pgxpool.Config, error)

PoolConfig parses a pgx pool config, optionally disabling prepared statements for PgBouncer.

Directories

Path Synopsis
Package pgtest starts an ephemeral Postgres for tests via Testcontainers.
Package pgtest starts an ephemeral Postgres for tests via Testcontainers.

Jump to

Keyboard shortcuts

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