Documentation
¶
Overview ¶
Package preflight runs read-only checks against a PostgreSQL instance to answer: "is this database ready to be a DBGorilla collector source?"
Each check returns a storage-agnostic Result with a severity and, when relevant, copy-pastable fix commands. The check logic is isolated from pgx via the Inspector port; the pgxInspector adapter is the only thing that imports pgx, so the rules are unit-testable against an in-memory fake.
Index ¶
- func ContainsLib(libs, needle string) bool
- func DSNSummary(dsn string) string
- type Inspector
- type Report
- type Result
- func CheckExtension(ctx context.Context, ins Inspector) Result
- func CheckServerVersion(ctx context.Context, ins Inspector) Result
- func CheckSharedPreload(ctx context.Context, ins Inspector) Result
- func CheckStatsGrants(ctx context.Context, ins Inspector) Result
- func CheckTrackFunctions(ctx context.Context, ins Inspector) Result
- func CheckTrackIOTiming(ctx context.Context, ins Inspector) Result
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsLib ¶
ContainsLib reports whether a comma-separated preload list contains needle.
func DSNSummary ¶
DSNSummary returns a host/db-only view of a DSN, hiding credentials.
Types ¶
type Inspector ¶
type Inspector interface {
Summary() string
ServerVersionNum(ctx context.Context) (string, error)
ShowParam(ctx context.Context, name string) (string, error)
HasExtension(ctx context.Context, name string) (bool, error)
CanReadStats(ctx context.Context) error
}
Inspector is the port the checks read DB state through.
type Report ¶
type Report struct {
Results []Result
}
Report aggregates all check results from a run.
func Run ¶
Run opens a pgx connection to dsn and runs all checks. A connection failure short-circuits to a single Fail result.
func (Report) HasWarnings ¶
HasWarnings returns true if any result is a Warn.
type Result ¶
type Result struct {
Name string
Severity Severity
Detail string
// Fix, when non-empty, is copy-pastable remediation. Empty on OK.
Fix []string
}
Result is the outcome of one preflight check.
func CheckExtension ¶
CheckExtension requires the pg_stat_statements extension in the current DB.
func CheckServerVersion ¶
CheckServerVersion requires Postgres 13+.
func CheckSharedPreload ¶
CheckSharedPreload requires pg_stat_statements in shared_preload_libraries.
func CheckStatsGrants ¶
CheckStatsGrants requires the role to be able to read pg_stat_statements.
func CheckTrackFunctions ¶
CheckTrackFunctions warns if track_functions is 'none'.