db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host              string
	Port              int
	DBName            string
	Credential        credential.Credential
	CACertificatePath string
}

Config represents the configuration needed to connect to a database.

func BuildDBConfigFromEnv

func BuildDBConfigFromEnv() (Config, error)

BuildDBConfigFromEnv builds a Config from environment variables. Port is read from PGPORT, defaulting to 30432 (the CI host-mapped port). Optional: DB_HOST, DB_NAME, DB_USER, DB_PASSWORD, DB_CA_CERT_PATH

func (*Config) BuildDSN

func (c *Config) BuildDSN() string

BuildDSN builds the Data Source Name (DSN) string for connecting to the database. User and password are URL-encoded to handle special characters such as "@", ":", "/", etc.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the Config fields are set correctly.

type ErrorChecker

type ErrorChecker interface {
	IsErrNoRows(err error) bool
	IsUniqueConstraintError(err error) bool
}

ErrorChecker abstracts database error classification.

Directories

Path Synopsis
Package testutil provides database test utilities for integration tests.
Package testutil provides database test utilities for integration tests.

Jump to

Keyboard shortcuts

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