retention

package
v0.2.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 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 = [...]Field{
	{"journal_days", 7, 1, 7, day},
	{"events_info_days", 90, 1, 365, day},
	{"events_warn_days", 400, 1, 1095, day},
	{"audit_days", 400, 30, 1095, day},
	{"alerts_days", 90, 7, 730, day},
	{"check_samples_hours", 25, 25, 168, hour},
	{"check_daily_days", 90, 7, 730, day},
	{"host_history_days", 90, 7, 365, day},
	{"traffic_bucket_days", 400, 30, 3650, day},
	{"node_traffic_hour_days", 400, 30, 3650, day},
	{"networks_days", 7, 1, 7, day},
}

Fields lists the settings in display order.

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 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(key string) time.Duration

Duration is the named field 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