upgrade

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 18 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 upgrade replaces the running memspace binary with a release from GitHub. The server decides the target: a client upgrades to the server's version when the server is newer, so the two stay compatible. Failures are recorded so doctor, the web UI and the next session can tell the user.

Index

Constants

View Source
const FullBuild = true

FullBuild reports whether this binary includes the server (cgo builds do).

View Source
const RetryAfter = 6 * time.Hour

RetryAfter is how long a failed automatic upgrade waits before the next attempt at the same version.

Variables

This section is empty.

Functions

func Asset

func Asset(goos, goarch string, full bool) (string, error)

Asset is the release file for a platform: the full binary for builds that include the server, else the client.

func Auto

func Auto(ctx context.Context, dir, current, server string, opts Options) error

Auto upgrades the client to the server's version when the server is newer, at most once per RetryAfter for a version that failed. It records the outcome in dir and returns the error of an attempt it made.

func Executable

func Executable() (string, error)

Executable is the running binary's path with symlinks resolved.

func Install

func Install(ctx context.Context, opts Options) error

Install downloads opts.Version, checks it against the release's SHA256SUMS, runs it, and atomically replaces opts.Exe. The replaced binary is kept as Exe + ".prev". Running processes keep the old binary until they restart.

func Newer

func Newer(current, target string) bool

Newer reports whether target is a release newer than current, which must also be a release: development builds are never replaced.

func SaveState

func SaveState(dir string, st State) error

SaveState writes the state atomically.

Types

type Options

type Options struct {
	Exe     string // binary to replace (default: the running executable)
	Version string // release tag to install
	// BaseURL holds the release's files (default: the GitHub release).
	BaseURL string
	HTTP    *http.Client
	// Verify checks a downloaded binary before it replaces Exe (default:
	// runs it with --version).
	Verify func(path, version string) error
}

Options configures Install.

type State

type State struct {
	// Target and Error describe the last failed attempt; both are cleared
	// once the client runs the target version or newer.
	Target      string    `json:"target,omitempty"`
	Error       string    `json:"error,omitempty"`
	AttemptedAt time.Time `json:"attempted_at,omitzero"`
	// From/To/At describe the last successful upgrade.
	UpgradedFrom string    `json:"upgraded_from,omitempty"`
	UpgradedTo   string    `json:"upgraded_to,omitempty"`
	UpgradedAt   time.Time `json:"upgraded_at,omitzero"`
}

State records automatic upgrades in the client state directory.

func LoadState

func LoadState(dir string) State

LoadState reads the state; a missing or unreadable file is empty.

func (*State) Settle

func (st *State) Settle(current string) bool

Settle clears a recorded failure once the client runs the failed target or a newer version (upgraded by hand, say). It reports whether st changed.

Jump to

Keyboard shortcuts

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