state

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package state persists PullPilot's update bookkeeping in the data dir: when each new digest was first seen (for soak), the last digest applied per container, and digests known to fail health checks (never auto-retried).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {

	// FirstSeen maps "container/digest" -> first time we observed that digest
	// as the upstream target for the container. Drives the soak window.
	FirstSeen map[string]time.Time `json:"first_seen"`
	// BadDigests records digests that failed a health check; never retried.
	BadDigests map[string]bool `json:"bad_digests"`
	// LastApplied maps container key -> digest last successfully applied.
	LastApplied map[string]string `json:"last_applied"`
	// Notified records "container/digest" pairs already announced, so a soaking
	// or monitor-only update is notified once per new digest, not every cycle.
	Notified map[string]bool `json:"notified"`
	// contains filtered or unexported fields
}

State is the on-disk bookkeeping, guarded by a mutex and flushed atomically.

func Load

func Load(dir string) (*State, error)

Load reads state from dir/state.json, returning an empty state if absent.

func (*State) FirstNotify

func (s *State) FirstNotify(key, digest string) bool

FirstNotify reports whether this is the first notification for a given container/digest, recording it so repeated cycles don't re-notify.

func (*State) IsBad

func (s *State) IsBad(digest string) bool

IsBad reports whether a digest previously failed a health check.

func (*State) MarkApplied

func (s *State) MarkApplied(key, digest string)

MarkApplied records the digest last applied for a container and prunes that container's stale first-seen entries.

func (*State) MarkBad

func (s *State) MarkBad(digest string)

MarkBad flags a digest as health-check-failing so it is never retried.

func (*State) PeekSeen added in v0.1.2

func (s *State) PeekSeen(key, digest string) (time.Time, bool)

PeekSeen returns the recorded first-seen time for a container/digest without recording one (read-only views). ok is false if it has never been seen.

func (*State) SeenAt

func (s *State) SeenAt(key, digest string, now time.Time) time.Time

SeenAt records (once) the first time a container's target digest was observed and returns that timestamp. now lets callers inject the clock in tests.

Jump to

Keyboard shortcuts

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