plan

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package plan turns recovery objectives into backup settings (ADR-0223): Derive maps them to keys, Apply splices the keys into a file's bytes, CheckConfig runs the daemon's loader on the result and CheckRTO bounds the recovery time. It holds no rule of the daemon's own; cmd/funcdctl wires the flags and the files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(path string, merged []byte) ([]config.Finding, error)

CheckConfig runs the daemon's loader on merged (Decision 3): config.Parse with funcdctl's FUNCD_* environment, its error returned unchanged; then the warnings of CheckBackup and CheckBlob, in that order.

func CheckRTO

func CheckRTO(o Objectives) (time.Duration, error)

CheckRTO is (0, nil) without an RTO, else the bound and, when the RTO is below it, an *RTOError.

func Cron

func Cron(rpo time.Duration) (string, error)

Cron is the largest period P ≤ rpo ÷ 2 that divides the hour or the day, as a cron expression (ADR-0211 grammar): every P minutes, every P hours, or daily at the 24 h cap. rpo ÷ 2 under a minute is fault.Invalid naming --rpo.

func Ladder

func Ladder(keep time.Duration) (hourly, daily, weekly int)

Ladder gives (hourly, daily, weekly) in ADR-0203 Decision 5's units, 0 unused, so the longest kept class covers keep.

func RTOBound

func RTOBound(size, speed int64) time.Duration

RTOBound is ⌈size ÷ speed⌉ seconds, the download alone, capped at v1alpha1.MaxDuration; size and speed are above 0.

Types

type Change

type Change struct{ Key, Old, New string }

Change is one key Apply edited; Old "" ⇒ the key was absent.

func Apply

func Apply(doc []byte, kind v1.Kind, s []Setting) ([]byte, []Change, error)

Apply sets each of s in doc (Decision 4), every other byte kept: a present scalar's text is replaced in place, a missing key (or parent) is inserted after its parent mapping's last line at the indentation of that mapping's first child (top level: at the end of the document, before the next document marker). kind "" ⇒ doc is a config file of at most one document; else the key is set in the one document of that kind. A key under an alias, an anchor, a block scalar or a flow collection, or a config file of several documents, is fault.Invalid naming the key. A key already at its value is no Change.

type Component

type Component string

Component is what a plan sets: the platform backup, the KV export or the blob mirror keys of funcdconfig.yaml, or a BackupSchedule.

const (
	Platform Component = "platform"
	KV       Component = "kv"
	Blob     Component = "blob"
	Schedule Component = "schedule"
)

The components of ADR-0223 Decision 1.

type Objectives

type Objectives struct {
	RPO, Keep, RTO time.Duration
	Size, Speed    int64
}

Objectives are the operator's targets; a zero field was not given (Decision 1). Size and Speed are bytes and bytes per second.

type RTOError

type RTOError struct{ Target, Bound time.Duration }

RTOError is an RTO below the download time (Decision 5): the settings were accepted, nothing is printed or written.

func (*RTOError) Error

func (e *RTOError) Error() string

Error is Decision 5's impossible line.

func (*RTOError) ExitCode

func (e *RTOError) ExitCode() int

ExitCode is funcdctl's exit code for the error, 3.

type Setting

type Setting struct{ Key, Value string }

Setting is one derived key: Key the dotted path from the document root, Value the scalar's text.

func Derive

func Derive(c Component, o Objectives, cur config.Config) ([]Setting, error)

Derive maps o to c's keys (Decision 2); cur is config.Parse of the located file, read for the KV floor and the blob interval. An absent objective sets no key.

Jump to

Keyboard shortcuts

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