Documentation
¶
Overview ¶
Package alertengine runs the alert engine's goroutines (plan §8): ONE evaluator (reads the poller's snapshot, drives the state machine, enqueues the outbox — never sends), a SEPARATE globally-rate-limited notifier (drains the outbox, so a hung SMTP/bot can't stall evaluation or spam the box), and an externalized dead-man's-switch heartbeat. Read-and-notify only: zero docker writes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
EvalInterval time.Duration
NotifyMinInterval time.Duration
QuietStartHour int // -1 disables
QuietEndHour int
DeadMansURL string
DeadMansInterval time.Duration
AdminURL string // for the "open in dashboard" link in notifications
}
Config tunes the engine (from config.AlertingConfig).
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns the evaluator + notifier + heartbeat.
func New ¶
func New(store *alertstore.Store, snapFn func() *monitor.Snapshot, cfg Config, log *slog.Logger) *Engine
New builds an Engine. snapFn returns the latest poller snapshot (may be nil).
func (*Engine) RunEvaluator ¶
RunEvaluator ticks the evaluator until ctx is cancelled.
func (*Engine) RunHeartbeat ¶
RunHeartbeat pings an external cron-monitor so a dead dashboard is detected by something OTHER than itself (plan §8 dead-man's-switch). SSRF-guarded outbound.
func (*Engine) RunNotifier ¶
RunNotifier drains the outbox, globally rate-limited, until ctx is cancelled.