Documentation
¶
Overview ¶
Package database defines shared scanning, hooks and SQL value contracts without importing drivers.
Index ¶
- func ReportQuery(ctx context.Context, h Hooks, l *slog.Logger, e QueryEvent)
- func ReportTransaction(ctx context.Context, h Hooks, operation string, start time.Time, err error)
- func Scan(rows Rows, destination any, many bool) error
- type Hooks
- type JSON
- type QueryEvent
- type Row
- type Rows
- type TransactionEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportQuery ¶
ReportQuery emits only bounded operation/success/duration attributes to the configured logger. SQL and arguments are never logged.
func ReportTransaction ¶
ReportTransaction invokes transaction instrumentation without changing the database outcome.
Types ¶
type Hooks ¶
type Hooks struct {
BeforeBegin func(context.Context) error
AfterQuery func(context.Context, QueryEvent)
AfterTransaction func(context.Context, TransactionEvent)
}
Hooks run synchronously and must be concurrency safe. BeforeBegin can reject a transaction before acquiring resources.
type JSON ¶
JSON is a nullable JSON SQL value. Use it when scanning a whole JSON column without a tagged struct field.
type QueryEvent ¶
QueryEvent contains query diagnostics without parameter values. Statement is available only to explicit hooks. Never use Statement as a metric label or log SQL containing literal secrets.