configstate

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 8 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 configstate holds the configuration state Current and Global share: what was pushed, what is in force, and the checksum every configuration is identified by. What each one configures, what its checksum covers and what it reports stay with it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(v any) (string, error)

Checksum is the SHA-256 of v's JSON (map keys sorted): how a pushed configuration, settings and effective values are identified.

func Key

func Key(v any) string

Key is Checksum for a pushed configuration or settings, which decode from JSON and so always encode; an unencodable value gets the key of its error, which matches no encodable one.

Types

type Accepted

type Accepted struct {
	Values   addonutils.Values
	Checksum string
}

Accepted is the configuration in force in the object: its effective values and their checksum.

func (Accepted) Checkpoint

func (a Accepted) Checkpoint(cr *model.CurrentReport)

Checkpoint writes a as the settings checkpoint (AppliedValues), what the next boot restores.

type Outcome

type Outcome struct {
	// Err: not accepted; the last accepted configuration stays in force and the retry is held
	// until Until.
	Err   error
	Until time.Time
	// Changed: the effective values in force changed (the first accept included).
	Changed bool
}

Outcome is the result of Accept.

type State

type State struct {
	Pushed           string    // Pushed is the checksum last given to Accept, accepted or not.
	AcceptedChecksum string    // AcceptedChecksum is the one whose accept succeeded last.
	Accepted         *Accepted // Accepted is in force in the object; nil until the first accept.
}

State is what was given to Accept and what is in force. Configurations are identified by their checksum: most pushes repeat the content in a new value, and they must neither reconfigure the object nor cancel a run. Only Accept writes it; one loop owns it.

func (*State) Accept

func (s *State) Accept(checksum string, backoff *retry.Backoff, clock retry.Clock, configure func() (addonutils.Values, string, error)) Outcome

Accept records checksum as pushed and runs configure, which takes the configuration into the object and returns the effective values with their checksum. A failure keeps the last accepted configuration in force and holds its retry in backoff, keyed by checksum and counted from the failure (validation may take long).

func (State) InForce

func (s State) InForce(checksum string) bool

InForce reports whether the configuration of checksum is the one the object holds and Configured reports: the last accept was of it and it succeeded. Not so after another configuration was tried since, even if that one failed, so pushing the old one again reports Configured=true.

Jump to

Keyboard shortcuts

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