updatecheck

package
v0.9.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisabled = errors.New("update checks disabled")
	ErrCooldown = errors.New("check cooldown")
)
View Source
var ErrNoCandidate = errors.New("no stable candidate")

ErrNoCandidate distinguishes a valid response without a stable candidate from a failed check.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Version    string `json:"version"`
	ReleaseURL string `json:"release_url"`
}

Candidate is a stable release advertised by a controlled publishing channel.

func ParseFormula

func ParseFormula(body []byte) (Candidate, error)

ParseFormula reads a single line-start version declaration without executing Ruby. Indentation and trailing comments are allowed; ambiguous or malformed declarations fail the check.

func ParseGitHubRelease

func ParseGitHubRelease(body []byte, component string) (Candidate, error)

ParseGitHubRelease accepts stable tags only. The returned URL is built from the controlled repository and original validated tag, never from html_url.

type CheckResult

type CheckResult struct {
	Enabled           bool                   `json:"enabled"`
	Sources           map[string]SourceState `json:"sources"`
	RetryAfterSeconds int                    `json:"retry_after_seconds"`
}

CheckResult is a snapshot of the shared update checks.

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker owns the lifecycle and state shared by automatic and manual checks.

func NewChecker

func NewChecker(ctx context.Context, opts Options, sources map[string]Source) (*Checker, error)

NewChecker borrows its sources and ties their shared work to ctx, not to the context of an individual caller. Zero durations use the production defaults.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, manual bool) (CheckResult, error)

Check joins an in-flight check before applying the instance-wide manual cooldown. Canceling ctx stops only this caller's wait.

func (*Checker) Close

func (c *Checker) Close()

Close cancels and waits for the scheduler and all registered source work. It never closes a source's borrowed HTTP client.

func (*Checker) Snapshot

func (c *Checker) Snapshot() CheckResult

Snapshot returns an isolated, age-adjusted view without contacting a source.

func (*Checker) Start

func (c *Checker) Start()

Start begins one asynchronous check, then schedules checks after each interval.

type Options

type Options struct {
	Enabled                     bool
	Interval, Timeout, Cooldown time.Duration
	Now                         func() time.Time
	After                       func(time.Duration) <-chan time.Time
}

Options controls background checks, the shared deadline and manual cooldown.

type Source

type Source interface {
	Latest(context.Context) (Candidate, error)
}

Source checks the current candidate without falling back to release history.

func NewGitHubSource

func NewGitHubSource(client *http.Client, component string) Source

NewGitHubSource uses only the admin or gateway repository's latest release. Unknown components fail locally when checked.

func NewHomebrewSource

func NewHomebrewSource(client *http.Client) Source

NewHomebrewSource uses the currently published Formula, not standalone's latest release, which may have been published before Homebrew was updated.

type SourceState

type SourceState struct {
	Status      string     `json:"status"`
	Candidate   *Candidate `json:"candidate,omitempty"`
	LastAttempt time.Time  `json:"last_attempt"`
	LastSuccess time.Time  `json:"last_success"`
	Stale       bool       `json:"stale"`
	ErrorCode   string     `json:"error_code,omitempty"`
}

SourceState describes the latest attempt and, when present, its candidate. Candidates in stale or non-ready states are history, not actionable targets.

Jump to

Keyboard shortcuts

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