database

package
v0.0.0-...-96711fa Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT, MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(pool *pgxpool.Pool, log *slog.Logger) error

func NewConnPool

func NewConnPool(ctx context.Context, dbConnDSN string, log *slog.Logger, opts ...ConnPoolOption) (*pgxpool.Pool, io.Closer, error)

func RegisterPoolMetrics

func RegisterPoolMetrics(meter metric.Meter, pool *pgxpool.Pool) error

Types

type ConnPoolOption

type ConnPoolOption func(*pgxpool.Config)

func WithQueryTracer

func WithQueryTracer(tracer pgx.QueryTracer) ConnPoolOption

type QueryMetricsTracer

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

func NewQueryMetricsTracer

func NewQueryMetricsTracer(meter metric.Meter) (*QueryMetricsTracer, error)

func (*QueryMetricsTracer) TraceQueryEnd

func (t *QueryMetricsTracer) TraceQueryEnd(ctx context.Context, _ *pgx.Conn, data pgx.TraceQueryEndData)

func (*QueryMetricsTracer) TraceQueryStart

func (t *QueryMetricsTracer) TraceQueryStart(ctx context.Context, _ *pgx.Conn, data pgx.TraceQueryStartData) context.Context

type RequestStats

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

RequestStats accumulates per-request query count and total time spent in the database, so a request can be classified as DB-bound vs render-bound.

func WithRequestStats

func WithRequestStats(ctx context.Context) (context.Context, *RequestStats)

WithRequestStats attaches a fresh RequestStats to ctx. The query tracer adds to it on every query that runs under the returned context.

func (*RequestStats) DBDuration

func (rs *RequestStats) DBDuration() time.Duration

func (*RequestStats) Queries

func (rs *RequestStats) Queries() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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