advisor

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package advisor runs a set of rules over a parsed plan tree and collects findings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advisor

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

Advisor runs a fixed set of rules over every node in a plan tree.

func New

func New(rules ...Rule) *Advisor

New creates an Advisor that applies the given rules to every node it visits.

func (*Advisor) Analyze

func (a *Advisor) Analyze(plan *parser.Plan) []Finding

Analyze walks the full plan tree depth-first and returns all findings across all nodes and all rules. The order of findings matches the pre-order traversal of the tree (same order as node IDs).

type Finding

type Finding struct {
	Severity   Severity
	NodeID     int    // ID of the node that triggered this; look up via Plan.NodeByID
	NodeType   string // convenience copy of the node's type; avoids a lookup for display
	Message    string // short one-line summary
	Detail     string // longer explanation of why this is a problem
	Suggestion string // what to do about it
}

Finding is one piece of feedback emitted by a rule for a specific plan node.

type Rule

type Rule interface {
	Check(node parser.Node) []Finding
}

Rule inspects a single plan node and returns any findings. Returning nil or an empty slice means the node looks fine for this rule.

type Severity

type Severity int

Severity describes how serious a finding is.

const (
	Info  Severity = iota // informational; no action required
	Warn                  // something worth investigating
	Error                 // likely a real performance problem
)

func (Severity) String

func (s Severity) String() string

String returns the uppercase label for a severity level.

Jump to

Keyboard shortcuts

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