update

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 13 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 update checks for a newer flockd release. Two sources feed it: the coordinator's release channel (ConfigUpdate.latest_version / minimum_version / release_url — authoritative, the mesh knows the minimum it drains below) and the public version feed (the fallback for nodes without a session, and the source of the URL when the mesh sends none). It never installs anything: it tells the operator (status, SSE, CLI, TUI, desktop banner) and points at the release page. Brew users run `brew upgrade --cask tera`; signed self-update is gated on plan 01.

Index

Constants

View Source
const (
	SourceFeed = "feed"
	SourceMesh = "mesh"
)

Sources of a Result's versions.

View Source
const DefaultFeedURL = "https://api.teraflock.ai/v1/versions"

DefaultFeedURL is the control plane's public version feed.

Variables

View Source
var ErrFeedUnavailable = errors.New("update: version feed unavailable")

ErrFeedUnavailable wraps feed fetch failures (404 while the endpoint is being built, connection errors). The result is "unknown", not an error the operator sees.

Functions

func Compare

func Compare(a, b string) int

Compare orders two release versions (-1, 0, 1). Non-release inputs sort below every release.

func IsRelease

func IsRelease(v string) bool

IsRelease reports whether v is a plain release version (x.y.z with an optional v prefix). Anything else — "dev", "ad2a146-dev", "0.4.0-rc1" — is a development build.

Types

type Checker

type Checker struct {
	FeedURL string
	// Current is the running build version (main.version).
	Current string
	Client  *http.Client
	Log     *slog.Logger
	// Events receives `update_available` once per newly discovered
	// version. May be nil.
	Events *events.Hub
	// Activity gets an update_available row once per version. May be nil.
	Activity *activity.Ring
	// InitialDelay before the first check (lets the daemon finish booting)
	// and Interval between checks. Zero = 30s / 1h.
	InitialDelay time.Duration
	Interval     time.Duration
	// contains filtered or unexported fields
}

Checker polls the feed.

func (*Checker) ApplyMesh added in v0.5.0

func (c *Checker) ApplyMesh(latest, minimum, url string)

ApplyMesh takes the coordinator's release channel from a ConfigUpdate. Non-empty latest/minimum override the feed's from now on (the mesh is authoritative: it knows the minimum it drains below); url fills in for the feed's only when set. Empty latest and minimum mean the coordinator sent nothing and change nothing. The result is recorded immediately, so status.update.below_minimum flips as soon as the coordinator says so, and a newly discovered version is announced once like a feed result.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context) (Result, error)

Check fetches the feed now and records the result.

func (*Checker) Last

func (c *Checker) Last() (Result, bool)

Last returns the most recent successful check.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run checks after InitialDelay and then every Interval until ctx ends. Feed failures are logged once at info and then at debug: the endpoint may simply not exist yet.

type Feed

type Feed struct {
	Flockd struct {
		Latest  string `json:"latest"`
		Minimum string `json:"minimum"`
		URL     string `json:"url"`
	} `json:"flockd"`
	Desktop struct {
		Latest string `json:"latest"`
		URL    string `json:"url"`
	} `json:"desktop"`
}

Feed is the version feed document:

{"flockd":{"latest":"0.4.0","minimum":"0.3.0","url":"…"},
 "desktop":{"latest":"…","url":"…"}}

type Public

type Public struct {
	Available    bool      `json:"available"`
	Current      string    `json:"current"`
	Latest       string    `json:"latest"`
	Minimum      string    `json:"minimum,omitempty"`
	BelowMinimum bool      `json:"below_minimum,omitempty"`
	URL          string    `json:"url,omitempty"`
	CheckedAt    time.Time `json:"checked_at"`
}

Public is the wire shape shared by /api/v1/status.update, the update/check route and the SSE event (mirrors the Update schema).

type Result

type Result struct {
	// Available is true when Latest is a newer release than Current.
	// Always false for dev builds (never nag a developer's own binary).
	Available    bool
	Current      string
	Latest       string
	Minimum      string
	BelowMinimum bool
	URL          string
	CheckedAt    time.Time
	// Source names where Latest/Minimum came from: "mesh" when the
	// coordinator's release channel set them, else "feed".
	Source string
}

Result is one completed check.

func Evaluate

func Evaluate(current string, feed Feed, now time.Time) Result

Evaluate compares a feed against the running version.

func (Result) Public

func (r Result) Public() Public

Public converts a Result for the wire.

Jump to

Keyboard shortcuts

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