postgres

package
v0.0.0-...-16cf5c7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EnvTechURL = "CPS_POSTGRES_TECH_URL"
View Source
const EnvURL = "CPS_POSTGRES_URL"

Variables

This section is empty.

Functions

func Dump

func Dump(ctx context.Context, connStr, filepath string) error

Dump calls pg_dump binary.

func GetConnStr

func GetConnStr() (string, error)

func GetTechConnStr

func GetTechConnStr() (string, error)

func IsConnectionError

func IsConnectionError(err error) bool

func IsTableMissingErr

func IsTableMissingErr(err error) bool

IsTableMissingErr reports whether err is a PostgreSQL "undefined table" error (SQLSTATE 42P01).

Types

type BasePool

type BasePool interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
	Begin(ctx context.Context) (pgx.Tx, error)
	Close()
	Stat() *pgxpool.Stat
	Ping(ctx context.Context) error
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
}

type Pool

type Pool interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	SendBatch(ctx context.Context, b *pgx.Batch) error
	Close()
	WithTransaction(ctx context.Context, f func(context.Context, pgx.Tx) error) error
	Ping(ctx context.Context) error
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
}

func NewPool

func NewPool(ctx context.Context, retryCount int, minRetryTimeout time.Duration) (Pool, error)

func NewTechMetricsPool

func NewTechMetricsPool(ctx context.Context, retryCount int, minRetryTimeout time.Duration) (Pool, error)

type PoolProvider

type PoolProvider interface {
	Get(ctx context.Context) (Pool, error)
	Close()
}

func NewPoolProvider

func NewPoolProvider(retryCount int, minRetryTimeout time.Duration) PoolProvider

Source Files

  • dump.go
  • pool_provider.go
  • postgres.go

Jump to

Keyboard shortcuts

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