db

package
v0.61.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MigrationsRoot   = "db/migrations"
	DefaultListLimit = 50
	MaxListLimit     = 100
)

Variables

This section is empty.

Functions

func AdjustListLimit

func AdjustListLimit(limit, offset int) (int, int)

Types

type DB

type DB struct {
	Pool *pgxpool.Pool
	// contains filtered or unexported fields
}

func NewDB

func NewDB(config DBConfig, serviceName string) (*DB, error)

func (*DB) Close

func (db *DB) Close()

type DBConfig

type DBConfig struct {
	Enabled           bool          `yaml:"enabled"`
	Username          string        `yaml:"username"`
	Password          string        `yaml:"password"`
	Database          string        `yaml:"database"`
	Hostname          string        `yaml:"hostname"`
	Port              int           `yaml:"port"`
	MaxConns          int32         `yaml:"maxConns"`
	MinConns          int32         `yaml:"minConns"`
	MaxConnIdleTime   time.Duration `yaml:"maxConnIdleTime"`
	MaxConnLifetime   time.Duration `yaml:"maxConnLifetime"`
	HealthCheckPeriod time.Duration `yaml:"healthCheckPeriod"`

	// MigrationRetryTimeout and MigrationRetryInterval bound how long
	// runDBMigrations keeps retrying a dirty migration before giving up.
	// Services in a bundle can start in no particular order, and a
	// migration's DDL may depend on a schema/table that another
	// service's own migration creates (see e.g. the provisioner's
	// db/migrations, which FKs into the identity schema). Since the
	// postgres driver sends a whole migration file as a single implicit
	// transaction, a failed migration never leaves partial DDL behind —
	// only the dirty marker survives the rollback — so it's safe to
	// clear that marker and retry until the dependency appears.
	MigrationRetryTimeout  time.Duration `yaml:"migrationRetryTimeout"`
	MigrationRetryInterval time.Duration `yaml:"migrationRetryInterval"`
}

func (*DBConfig) ConnString

func (c *DBConfig) ConnString() string

func (*DBConfig) SetDefaults

func (c *DBConfig) SetDefaults()

Jump to

Keyboard shortcuts

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