pg

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 20 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// DriverPostgres represents the postgres dialect.
	DriverPostgres = "pgx"
	// DriverTxWrappedPostgres is useful for tests.
	// When the connection is opened, it starts a transaction and all
	// operations performed on the DB will be within that transaction.
	DriverTxWrappedPostgres = "txdb"
	// DriverInMemoryPostgres uses an in memory database, github.com/marcboeker/go-duckdb.
	DriverInMemoryPostgres = "duckdb"
)

Variables

This section is empty.

Functions

func NewTestDB deprecated

func NewTestDB(t testing.TB, dbURL string) *sqlx.DB

Deprecated: Use sqltest.NewDB

func SetApplicationName added in v0.5.0

func SetApplicationName(u *url.URL, name string)

func TestURL deprecated

func TestURL(t testing.TB) string

Deprecated: Use sqltest.TestURL

Types

type DBConfig added in v0.5.0

type DBConfig struct {
	IdleInTxSessionTimeout     time.Duration // idle_in_transaction_session_timeout
	LockTimeout                time.Duration // lock_timeout
	MaxOpenConns, MaxIdleConns int
	EnableTracing              bool
}

func (DBConfig) New added in v0.5.0

func (config DBConfig) New(ctx context.Context, uri string, driverName string) (*sqlx.DB, error)

func (DBConfig) OtelOpts added in v0.9.0

func (config DBConfig) OtelOpts() []otelsql.Option

func (DBConfig) WithTracing added in v0.9.0

func (config DBConfig) WithTracing(enabled bool) DBConfig

type DialectName deprecated

type DialectName string

Deprecated: Use Driver* constants

const (
	// Deprecated: Use DriverPostgres
	Postgres DialectName = DriverPostgres
	// Deprecated: Use DriverTxWrappedPostgres
	TransactionWrappedPostgres DialectName = DriverTxWrappedPostgres
	// Deprecated: Use DriverTxWrappedPostgres DriverInMemoryPostgres
	InMemoryPostgres DialectName = DriverInMemoryPostgres
)

type ReportFn added in v0.5.0

type ReportFn func(sql.DBStats)

type StatFn added in v0.5.0

type StatFn func() sql.DBStats

type StatsReporter added in v0.5.0

type StatsReporter struct {
	// contains filtered or unexported fields
}

func NewStatsReporter added in v0.5.0

func NewStatsReporter(fn StatFn, lggr logger.Logger, opts ...StatsReporterOpt) *StatsReporter

func (*StatsReporter) Start added in v0.5.0

func (r *StatsReporter) Start()

func (*StatsReporter) Stop added in v0.5.0

func (r *StatsReporter) Stop()

Stop stops all resources owned by the reporter and waits for all of them to be done

type StatsReporterOpt added in v0.5.0

type StatsReporterOpt func(*StatsReporter)

func StatsCustomReporterFn added in v0.5.0

func StatsCustomReporterFn(fn ReportFn) StatsReporterOpt

func StatsInterval added in v0.5.0

func StatsInterval(d time.Duration) StatsReporterOpt

Jump to

Keyboard shortcuts

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