Documentation
¶
Overview ¶
Package updatefeed is the update feed of the ActNow apps on actnow.dev (or refto.one) as a source of MyGo's updater (mygo.Updater.SetSource):
<Base>/update-<target>.json releases (the stable channel)
<Base>/beta/update-<target>.json the beta channel: the newest version
of both channels, as the site keeps it
A Source reads the releases' manifest, or with the beta channel both manifests and the newer of the two; downloads the archive or delta the manifest names through the app's own transport (its proxy rule), going on with a Range request from where a download broke off; and says "nothing published" for a channel without a manifest (404), which MyGo reports as no update. It does not check what it downloads: MyGo checks the size and the release signature, made with the app's key, of every archive and delta, whatever its source.
actnowkit does not depend on MyGo: Source has the methods of mygo.UpdateSource (Go interfaces are structural), so the app passes it as it is:
mygo.Updater.SetSource(&updatefeed.Source{
Base: "https://actnow.dev/updates/dicta",
Target: "darwin-arm64",
Beta: func() bool { return settings.Beta() },
Transport: netclient.Transport(),
})
Index ¶
Constants ¶
const BetaDir = "beta"
BetaDir is the directory of the beta channel beside the releases' manifests (MyGo's update.PrereleaseDir, the site's channel directory).
const MaxManifestSize = 1 << 20
MaxManifestSize is the most a manifest may hold, as MyGo reads it.
Variables ¶
var ErrNotPublished = fmt.Errorf("updatefeed: nothing published: %w", fs.ErrNotExist)
ErrNotPublished is wrapped by Manifest's error when the channels read have no manifest (404): nothing is published there yet, or every release was withdrawn. It is an fs.ErrNotExist (errors.Is), which MyGo's Check reports as no update rather than as an error.
Functions ¶
func Compare ¶
Compare compares versions such as 1.2.3 and 1.3.0-beta.1 as MyGo's updater does (semantic versioning: numbers numerically, a pre-release before its release, build metadata ignored).
func IsPrerelease ¶
IsPrerelease reports whether a version such as 1.3.0-beta.1 is a prerelease (the beta channel's).
Types ¶
type Source ¶
type Source struct {
// Base is the feed's directory, the updates.url of the releases:
// "https://actnow.dev/updates/dicta" (without /beta).
Base string
// Target is MyGo's build target, which names the manifest:
// "darwin-arm64", "darwin-universal". Empty: GOOS-GOARCH.
Target string
// Beta reports whether the app reads the beta channel even when MyGo
// does not ask for prereleases (mygo.Updater.SetPrereleases), such as
// an app running a beta whose user never chose: nil reads it only when
// asked. Called at each check.
Beta func() bool
// Transport is how the source reaches the network: the app's proxy
// rule, retries, a fallback to a direct connection. Nil:
// http.DefaultTransport. Redirects are followed to HTTPS only.
Transport http.RoundTripper
// UserAgent of the requests; empty: "actnowkit-updatefeed".
UserAgent string
// HeaderTimeout is how long a response's headers may take (default
// 30 s); StallTimeout how long a body may send nothing before the
// connection is given up and resumed (default 1 minute).
HeaderTimeout, StallTimeout time.Duration
// Resumes is how many times in a row a download that broke off is
// asked for again from where it stopped (default 5; negative: none),
// ResumeWait how long before the first time, doubling after each
// (default 1 s). A resume that brings bytes starts the count again.
Resumes int
ResumeWait time.Duration
// Log receives a line for each fallback and resume (nil: none).
Log func(string)
// contains filtered or unexported fields
}
Source is an update feed of the ActNow site. Its zero value is not usable: set Base. Safe for concurrent use; its fields must not change once in use.
func (*Source) Manifest ¶
Manifest returns the manifest of the app's target, as MyGo's UpdateSource: the releases', or with prereleases (or Beta) the newer of the beta channel's and the releases'. When one channel's cannot be read it returns the other's; when neither has one, an error wrapping ErrNotPublished; else the releases' error, or the beta channel's when the releases have nothing published.
func (*Source) ManifestURL ¶
ManifestURL is the URL of the manifest of a channel: the releases', or with beta the beta channel's.
func (*Source) Open ¶
Open returns the file at rawURL, which the manifest names (the archive of an update or one of its deltas), as MyGo's UpdateSource: over HTTPS (plain HTTP on the loopback interface, for tests), through Transport. A body whose connection fails part way is asked for again from where it stopped (Resumes). A 404 is ErrNotPublished.
type StatusError ¶
StatusError is a response other than the one asked for. A 404 is ErrNotPublished (errors.Is).
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Is ¶
func (e *StatusError) Is(target error) bool
Is reports a 404 as ErrNotPublished and fs.ErrNotExist.