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
- func Asset(goos, goarch string, full bool) (string, error)
- func Auto(ctx context.Context, dir, current, server string, opts Options) error
- func Executable() (string, error)
- func Install(ctx context.Context, opts Options) error
- func Newer(current, target string) bool
- func SaveState(dir string, st State) error
- type Options
- type State
Constants ¶
const FullBuild = true
FullBuild reports whether this binary includes the server (cgo builds do).
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 ¶
Asset is the release file for a platform: the full binary for builds that include the server, else the client.
func Auto ¶
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 ¶
Executable is the running binary's path with symlinks resolved.
func Install ¶
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.
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.