config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config loads and validates pgwatch's YAML configuration file.

Index

Constants

View Source
const (
	OutputTerminal = "terminal" // print findings to stdout
	OutputJSON     = "json"     // write findings to a JSON file (requires OutFile)
	OutputHTML     = "html"     // write a self-contained HTML report (requires OutFile)
)

Output destination constants. The Output field in Config must be one of these.

View Source
const (
	SourceAutoExplain = "auto_explain" // tail the PostgreSQL log file for auto_explain output
)

Source type constants. The Source field in Config must be one of these.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Source selects which plan source to use.
	// Supported values: "auto_explain".
	// Default: "auto_explain".
	Source string `yaml:"source"`

	// LogFile is the path to the PostgreSQL log file that contains auto_explain output.
	// Required when source is "auto_explain".
	// Example: /var/log/postgresql/postgresql-14-main.log
	LogFile string `yaml:"log_file"`

	// Interval controls how often accumulated findings are flushed to the reporter.
	// In daemon mode (pgwatch run), a report is printed every Interval.
	// Default: 1h.
	Interval time.Duration `yaml:"interval"`

	// MaxBufferedPlans is the maximum number of plans held in memory between
	// report flushes. When the limit is reached, a flush is triggered immediately
	// instead of waiting for the next Interval tick — preventing unbounded memory
	// growth during high-traffic periods.
	// Default: 1000.
	MaxBufferedPlans int `yaml:"max_buffered_plans"`

	// Output selects the report destination.
	// Supported values: "terminal", "json", "html".
	// Default: "terminal".
	Output string `yaml:"output"`

	// OutFile is the file path for JSON output.
	// Required when Output is "json".
	// Example: /tmp/pgwatch-report.json
	OutFile string `yaml:"out_file"`
}

Config holds all pgwatch runtime settings loaded from the YAML config file.

func Load

func Load(path string) (*Config, error)

Load reads the YAML file at path, applies defaults, and validates the result.

Jump to

Keyboard shortcuts

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