health

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package health provides health check and readiness probe support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatResults added in v0.2.0

func FormatResults(suite *DiagnosticSuite) string

FormatResults produces a human-readable terminal output of diagnostic results.

func SuggestFixes added in v0.2.0

func SuggestFixes(suite *DiagnosticSuite) []string

SuggestFixes returns prioritized fix suggestions from the suite results. Failures are listed first, then warnings.

Types

type Check

type Check struct {
	Name        string        `json:"name"`
	Status      Status        `json:"status"`
	Message     string        `json:"message,omitempty"`
	LastChecked time.Time     `json:"last_checked"`
	Duration    time.Duration `json:"duration_ms,omitempty"`
}

Check represents a health check.

type Checker

type Checker func(ctx context.Context) Check

Checker is a function that performs a health check.

func APIKeyChecker

func APIKeyChecker(provider, key string) Checker

APIKeyChecker checks if an API key is configured.

func DiskSpaceChecker

func DiskSpaceChecker(minFreeGB int) Checker

DiskSpaceChecker checks available disk space.

type DiagnosticCheck added in v0.2.0

type DiagnosticCheck struct {
	Name     string
	Category string
	RunFn    func() DiagnosticResult
}

DiagnosticCheck defines a single named check with a category and run function.

type DiagnosticResult added in v0.2.0

type DiagnosticResult struct {
	Name     string
	Status   string // "pass", "warn", "fail"
	Message  string
	Fix      string
	Duration time.Duration
}

DiagnosticResult holds the outcome of a single diagnostic check.

type DiagnosticSuite added in v0.2.0

type DiagnosticSuite struct {
	Results   []DiagnosticResult
	StartTime time.Time
	Duration  time.Duration
}

DiagnosticSuite holds the collected results from running diagnostics.

type Diagnostics added in v0.2.0

type Diagnostics struct {
	Checks []DiagnosticCheck
	// contains filtered or unexported fields
}

Diagnostics manages a collection of diagnostic checks.

func NewDiagnostics added in v0.2.0

func NewDiagnostics() *Diagnostics

NewDiagnostics creates a Diagnostics instance with built-in checks across environment, config, network, tools, and permissions categories.

func (*Diagnostics) QuickCheck added in v0.2.0

func (d *Diagnostics) QuickCheck() bool

QuickCheck returns true if all critical checks (those that would "fail") pass. It runs all checks and returns false if any check has status "fail".

func (*Diagnostics) RunAll added in v0.2.0

func (d *Diagnostics) RunAll() *DiagnosticSuite

RunAll executes all registered diagnostic checks and returns a suite of results.

func (*Diagnostics) RunCategory added in v0.2.0

func (d *Diagnostics) RunCategory(category string) *DiagnosticSuite

RunCategory executes only the checks matching the given category.

type Registry

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

Registry manages health checks.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new health check registry.

func (*Registry) Register

func (r *Registry) Register(name string, checker Checker)

Register registers a health check.

func (*Registry) Result

func (r *Registry) Result(name string) (Check, bool)

Result returns the result of a specific check.

func (*Registry) Run

func (r *Registry) Run(ctx context.Context) map[string]Check

Run runs all health checks.

func (*Registry) Status

func (r *Registry) Status() Status

Status returns the overall health status.

type Status

type Status string

Status represents health status.

const (
	Healthy   Status = "healthy"
	Unhealthy Status = "unhealthy"
	Degraded  Status = "degraded"
)

Jump to

Keyboard shortcuts

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