retention

package
v0.2.0-dev.14 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package retention holds the owner's retention settings: how long each table the sweep prunes keeps its rows. Every value is a whole number stored as the setting "retention.<name>"; a missing or unusable value means the default, which is what the panel always did. The package is small and has no dependencies because the health sweep reads it on every edition.

Index

Constants

View Source
const Prefix = "retention."

Prefix starts every retention setting key.

Variables

View Source
var Fields = [numKeys]Field{
	JournalDays:         {"journal_days", 7, 1, 7, day},
	EventsInfoDays:      {"events_info_days", 90, 1, 365, day},
	EventsWarnDays:      {"events_warn_days", 400, 1, 1095, day},
	AuditDays:           {"audit_days", 400, 30, 1095, day},
	AlertsDays:          {"alerts_days", 90, 7, 730, day},
	CheckSamplesHours:   {"check_samples_hours", 25, 25, 168, hour},
	CheckDailyDays:      {"check_daily_days", 90, 7, 730, day},
	HostHistoryDays:     {"host_history_days", 90, 7, 365, day},
	TrafficBucketDays:   {"traffic_bucket_days", 400, 30, 3650, day},
	NodeTrafficHourDays: {"node_traffic_hour_days", 400, 30, 3650, day},
	NetworksDays:        {"networks_days", 7, 1, 7, day},
}

Fields lists the settings in display order; Fields[k] is the field of Key k.

Functions

func Keys

func Keys() []string

Keys lists the setting keys, for one batched read.

Types

type Field

type Field struct {
	Key      string // the part after Prefix, also the MCP and RPC name
	Default  int
	Min, Max int
	Unit     time.Duration // what one unit of the value is: an hour or a day
}

Field is one retention setting.

func (Field) Valid

func (f Field) Valid(v int) bool

Valid reports whether v is within the field's limits.

type Key

type Key int

Key names one retention setting in code. A misspelt Key does not compile, where a misspelt name used to read as a zero window and the prune that follows would delete the whole table.

const (
	JournalDays Key = iota
	EventsInfoDays
	EventsWarnDays
	AuditDays
	AlertsDays
	CheckSamplesHours
	CheckDailyDays
	HostHistoryDays
	TrafficBucketDays
	NodeTrafficHourDays
	NetworksDays
)

type Policy

type Policy struct{ Values [len(Fields)]int }

Policy is the effective retention: Values[i] belongs to Fields[i].

func Default

func Default() Policy

Default is the policy of a panel whose owner never changed anything.

func Parse

func Parse(stored map[string]string) Policy

Parse reads stored settings (as SettingValues returns them). A value that is not a number, or is out of its limits, is the default: a hand-edited row cannot make the sweep delete everything.

func (Policy) Duration

func (p Policy) Duration(k Key) time.Duration

Duration is the field k as a duration.

func (Policy) Get

func (p Policy) Get(key string) (int, bool)

Get returns the value of the named field and whether the name exists.

Jump to

Keyboard shortcuts

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