alertengine

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

func (e *Engine) RunEvaluator(ctx context.Context)

RunEvaluator ticks the evaluator until ctx is cancelled.

func (*Engine) RunHeartbeat

func (e *Engine) RunHeartbeat(ctx context.Context)

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

func (e *Engine) RunNotifier(ctx context.Context)

RunNotifier drains the outbox, globally rate-limited, until ctx is cancelled.

Jump to

Keyboard shortcuts

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