database

package
v0.0.0-...-1e98429 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgres

func NewPostgres(ctx context.Context, config PGConfig) (*pgxpool.Pool, error)

NewPostgres creates a PostgreSQL database handle that uses a pool of connections to allow for safe concurrent use and verifies a connection can be established.

Types

type PGConfig

type PGConfig struct {
	Scheme             string
	Host               string
	Port               int
	Name               string
	User               string
	Password           string
	ConnectTimeout     int
	SSLMode            string
	SSLCert            string
	SSLKey             string
	SSLRootCert        string
	PoolMinConnections int
	PoolMaxConnections int
	PoolMaxConnLife    time.Duration
	PoolMaxConnIdle    time.Duration
	PoolHealthcheck    time.Duration
}

PGConfig holds the information required for a PostgreSQL database connection.

func (PGConfig) ConnectionURL

func (c PGConfig) ConnectionURL() string

ConnectionURL builds a connection string suitable for a database.

func (PGConfig) LogValue

func (c PGConfig) LogValue() slog.Value

LogValue implements the slog.LogValuer interface to prevent the leaking of sensitive information in logs.

Jump to

Keyboard shortcuts

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