Documentation
¶
Overview ¶
Package health probes scan engines for liveness and latency and exposes a snapshot for the admin console. It is protocol-agnostic: liveness checks are injected as closures, so this package does not import internal/scanner.
Index ¶
- type Monitor
- func (m *Monitor) AddActive(name, detail string, enabled bool, probe Probe)
- func (m *Monitor) AddDisabled(name, detail string)
- func (m *Monitor) AddPassive(name, detail string, enabled bool, report Reporter)
- func (m *Monitor) Close() error
- func (m *Monitor) Snapshot() []ScannerHealth
- func (m *Monitor) Start()
- type Probe
- type Reporter
- type Sample
- type ScannerHealth
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor probes active scanners on a timer and classifies all registered engines for the console. Register entries with Add* before calling Start.
func NewMonitor ¶
NewMonitor returns a monitor that probes every interval and flags latencies above slow as warn. A non-positive interval falls back to 30s; a non-positive slow disables the warn state.
func (*Monitor) AddDisabled ¶
AddDisabled registers a configured-but-unattached engine (always reported off).
func (*Monitor) AddPassive ¶
AddPassive registers an engine that reports its own last outcome.
func (*Monitor) Close ¶
Close stops the probe loop and waits for it to exit. Safe to call once; extra calls are no-ops.
func (*Monitor) Snapshot ¶
func (m *Monitor) Snapshot() []ScannerHealth
Snapshot returns the current health of every registered engine, in registration order.
type Reporter ¶
type Reporter func() Sample
Reporter returns the current passive sample for an engine that tracks its own outcomes (e.g. the osv.dev client).
type Sample ¶
type Sample struct {
OK bool // last check/scan succeeded
Latency time.Duration // observed round-trip
HasData bool // false means "never checked" → unknown
}
Sample is one raw liveness observation, before classification.
type ScannerHealth ¶
type ScannerHealth struct {
Name string `json:"name"`
Detail string `json:"detail"`
Enabled bool `json:"enabled"`
Status Status `json:"status"`
LatencyMS int64 `json:"latency_ms"`
}
ScannerHealth is the per-engine record surfaced in GET /api/overview.
type Status ¶
type Status string
Status is a scan engine's health classification.
const ( StatusOK Status = "ok" // reachable, latency within threshold StatusWarn Status = "warn" // reachable but slow (latency over threshold) StatusDown Status = "down" // last check failed StatusUnknown Status = "unknown" // not checked yet / no traffic yet StatusOff Status = "off" // configured but not attached by the active profile )