updater

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package updater checks GitHub releases and replaces the running binary. It owns the release asset naming (see scripts/build) and never touches processes or databases: callers stop and start the server around Swap.

Index

Constants

View Source
const (
	// Repository is the GitHub repository that publishes releases.
	Repository = "TheSlopMachine/llm-router"
	// DefaultAPIBase is the GitHub REST API root.
	DefaultAPIBase = "https://api.github.com"
	// ChecksumsAssetName is the checksum list published with each release.
	ChecksumsAssetName = "checksums.txt"

	MaxArchiveBytes  int64 = 256 << 20
	MaxChecksumBytes int64 = 1 << 20
)

Variables

View Source
var ErrNoRelease = errors.New("no release published")

ErrNoRelease reports a repository without a published release.

Functions

func AssetName

func AssetName(goos, goarch string) string

AssetName returns the release archive name for a platform.

func Compare

func Compare(current, latest version.Version) int

Compare orders two versions: negative when current is older than latest, zero when equal, positive when newer.

func Discard

func Discard(staging string)

Discard removes a staged binary.

func ExtractBinary

func ExtractBinary(archive []byte, binaryName string) ([]byte, error)

ExtractBinary returns the named executable from a release archive.

func Stage

func Stage(executable string, binary []byte) (string, error)

Stage writes the new binary next to executable and returns its path. Callers run it once to confirm it works before Swap.

func Swap

func Swap(executable, staging string) (string, error)

Swap replaces executable with the staged binary and keeps the old one as the previous version. Renaming a running executable is allowed on every supported OS, so the running process keeps its old code until restart.

func VerifyChecksum

func VerifyChecksum(checksums []byte, assetName string, data []byte) error

VerifyChecksum checks data against the entry for assetName in a checksums.txt body ("<sha256> <dir>/<name>" per line).

Types

type Client

type Client struct {
	HTTPClient *http.Client
	APIBase    string
	Repository string
}

Client talks to the GitHub API. The zero value uses the public API.

func (Client) Download

func (client Client) Download(ctx context.Context, url string, limit int64) ([]byte, error)

Download fetches url into memory and fails above limit bytes.

func (Client) Latest

func (client Client) Latest(ctx context.Context) (Release, error)

Latest fetches the newest non-draft, non-prerelease release.

type Release

type Release struct {
	Tag    string
	Assets map[string]string
}

Release is the latest published release.

Jump to

Keyboard shortcuts

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