config

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config loads natsie's configuration from a YAML file and environment variables, layered in that order.

File: ~/.config/natsie/config.yaml (override with --config or NATSIE_CONFIG). Env: any variable prefixed NATSIE_, with double-underscore as the section separator so single underscores can appear inside field names. For example

NATSIE_DEFAULTS__MIN_PENDING=10000
sets defaults.min_pending to 10000.

Command-line flags are applied on top of this in the calling command (urfave CLI v3 manages flag state on the *cli.Command itself, so we layer it there rather than via a koanf flag provider).

Index

Constants

View Source
const (
	// KindConsumerStale scans a stream's consumers and reports the stale
	// ones as a cleanup manifest (the original, approval-gated flow).
	KindConsumerStale = "consumer-stale"
	// KindStreamUnlimited reports streams with no retention limit. It is a
	// notify-only report — no manifest, no approval, nothing is deleted.
	KindStreamUnlimited = "stream-unlimited"
	// KindPeerCheck reports ghost peers (offline in every Raft group, leading
	// none). Notify-only — natsie never evicts a peer itself.
	KindPeerCheck = "peer-check"
	// KindStreamReport reports under-replicated (R<2) streams with a
	// placement-skew summary. Notify-only — fixing replication is a human
	// stream edit, not a natsie action.
	KindStreamReport = "stream-report"
)

Schedule kinds. An empty Kind is treated as KindConsumerStale so existing configs keep working without change.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Schedules  []Schedule `koanf:"schedules"`
	Notify     []string   `koanf:"notify"`
	Owners     []Owner    `koanf:"owners"`
	Store      string     `koanf:"store"`
	AuditLog   string     `koanf:"audit_log"`
	HTTP       HTTP       `koanf:"http"`
	SigningKey string     `koanf:"signing_key"`
	Mattermost Mattermost `koanf:"mattermost"`
}

Bot holds everything `natsie bot serve` needs to run unattended. Each schedule produces manifests, the store persists them, the notify list announces them, and the HTTP listener exposes them.

type Config

type Config struct {
	Defaults Defaults                  `koanf:"defaults"`
	Contexts map[string]ContextOptions `koanf:"contexts"`
	// Protect lists consumers natsie must never delete because another
	// system owns their lifecycle. It applies to every deletion path —
	// CLI apply, bot auto-delete, and signed approvals alike.
	Protect protect.Config `koanf:"protect"`
	Bot     Bot            `koanf:"bot"`
}

func Load

func Load(path string) (*Config, error)

Load reads the config file (if it exists) and overlays environment variables. An absent file is not an error — defaults stand in.

type ContextOptions

type ContextOptions struct {
	Peer string `koanf:"peer"`
}

ContextOptions lets the user pre-declare cluster topology so the bot does not need a --peer-context flag on every invocation.

type Defaults

type Defaults struct {
	MinPending int64         `koanf:"min_pending"`
	MinIdle    time.Duration `koanf:"min_idle"`
	Format     string        `koanf:"format"`
}

type HTTP

type HTTP struct {
	Listen  string `koanf:"listen"`
	BaseURL string `koanf:"base_url"`
}

HTTP configures the bot's listener used for the manifest viewer, slash-command webhook, and approval URLs.

type Mattermost added in v0.4.0

type Mattermost struct {
	Enabled   bool   `koanf:"enabled"`
	Server    string `koanf:"server"`
	Token     string `koanf:"token"`
	TokenFile string `koanf:"token_file"`
	Team      string `koanf:"team"`
	Channel   string `koanf:"channel"`
	Trigger   string `koanf:"trigger"`
}

Mattermost is the pull-mode listener block: natsie opens a WebSocket to Server using a bot-account token, listens for posts in Channel on Team, and reacts to messages starting with Trigger. Leave Enabled false (or omit the block entirely) to run with push-mode only.

Token may be supplied directly or via TokenFile; the file path takes priority so the secret can live in a mounted Kubernetes Secret rather than in env/yaml.

type Owner

type Owner struct {
	Name           string   `koanf:"name"`
	Streams        []string `koanf:"streams"`
	ConsumerPrefix []string `koanf:"consumer_prefix"`
	Notify         []string `koanf:"notify"`
}

Owner routes a subset of manifest entries to a team-specific notify list. An entry matches an owner if its stream appears in Streams (exact match) or its consumer name starts with one of ConsumerPrefix. Matching is first-hit, evaluated in the order the owners appear in config.

type Schedule

type Schedule struct {
	Name        string        `koanf:"name"`
	Cron        string        `koanf:"cron"`
	Kind        string        `koanf:"kind"`
	Context     string        `koanf:"context"`
	PeerContext string        `koanf:"peer_context"`
	Stream      string        `koanf:"stream"`
	MinPending  int64         `koanf:"min_pending"`
	MinIdle     time.Duration `koanf:"min_idle"`
	// AutoDelete turns this schedule from propose-and-wait into
	// scan-and-delete: stale consumers are deleted on the spot instead of
	// being written to a manifest and announced with an approval link.
	// Re-verification and protection still run at delete time. Only
	// meaningful for KindConsumerStale.
	AutoDelete bool `koanf:"auto_delete"`
}

Schedule is one recurring scan. Cron uses standard 5-field syntax (or @daily/@hourly/etc.). Kind selects what the schedule does; the consumer-stale fields (Stream/MinPending/MinIdle/PeerContext) are ignored by kinds that don't use them.

Jump to

Keyboard shortcuts

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