config

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-2.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config reads and validates knell's environment configuration. All environment reads live here; the rest of the app receives the parsed Config. Malformed required values fail startup with a clear error rather than falling back: a dead-man watcher silently running with the wrong beats or webhook is worse than one that refuses to start.

Index

Constants

View Source
const MaxBeats = 64

MaxBeats caps how many beats one instance will watch. The cap keeps the metric label space and the notification fan-out operator-bounded; a config past it is almost certainly a generator bug.

View Source
const MinDeadline = 30 * time.Second

MinDeadline is the smallest accepted beat deadline. Anything shorter turns transient sender hiccups into alert spam; a sender that beats more often than every 30 seconds still works with a longer deadline.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beat

type Beat struct {
	ID       string
	Deadline time.Duration
}

Beat is one watched heartbeat: an id senders ping and the silence deadline after which the beat is declared missing.

func ParseBeats

func ParseBeats(raw string) ([]Beat, error)

ParseBeats parses the BEATS spec list: comma-separated "id:deadline" entries, e.g. "watchdog-mimir:20m,watchdog-loki:20m". IDs must match [A-Za-z0-9][A-Za-z0-9_-]{0,63} and be unique; deadlines are Go durations of at least MinDeadline.

type Config

type Config struct {
	WebhookURL string
	Node       string
	ListenAddr string
	Beats      []Beat
	LogLevel   slog.Level
}

Config is the fully parsed runtime configuration.

func Load

func Load() (Config, error)

Load reads the environment and returns the validated configuration. BEATS and DISCORD_WEBHOOK_URL are required; everything else has a default.

Jump to

Keyboard shortcuts

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