Documentation
¶
Overview ¶
Package changelog polls for new releases and notifies connected clients.
Index ¶
Constants ¶
const TagsAPIURL = "https://git.thc420.dev/api/v1/repos/ouch/relay/tags"
TagsAPIURL mirrors changelog.ts's TAGS_API_URL: this fork's own Gitea tags endpoint, not upstream's GitHub releases (see prior memory on the update-check-uses-fork's-own-tags migration).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker mirrors changelog.ts's module-level `changelog`/`versions` singleton, wrapped in a struct per this codebase's usual pattern for what was process-global state in Node.
func New ¶
New mirrors the module's initial `versions` value. bindAddr is Config.values.bind (the outgoing local address to bind requests to, "" for the OS default); currentVersion/homepage/userAgent are the package.json-derived values Node reads via createRequire - this package has no equivalent of package.json, so callers supply them explicitly (from wherever Stage 12/13 ends up sourcing the Go binary's own version).
func (*Checker) Fetch ¶
Fetch mirrors changelog.ts's fetch(): serves the cached result while unexpired, otherwise queries the tags API and recomputes it. Any request/decode failure - or a non-200 response - falls back to returning whatever was previously cached (possibly still the untouched zero-state on the very first call), matching fetch()'s own fall-through-on-failure behavior.
func (*Checker) IsUpdateAvailable ¶
IsUpdateAvailable mirrors reading `changelog.isUpdateAvailable`.
func (*Checker) StartPolling ¶
StartPolling mirrors checkForUpdates: fetches immediately, broadcasts "changelog:newversion" to every connection on hub whenever the result carries a Latest (every settled fetch, not just the first one to find one - matching Node calling this unconditionally each time), and reschedules itself roughly every 24 hours with jitter until an update is known to be available, at which point (mirroring Node exactly) it stops rescheduling - there's nothing more to poll for once one's been found. Returns once ctx is canceled or polling stops.
type Current ¶
type Current struct {
Prerelease bool `json:"prerelease"`
Version string `json:"version"`
Changelog string `json:"changelog,omitempty"`
// URL is always "" - changelog.ts itself never sets it (marked `// TODO:
// properly init` in the original), preserved here rather than
// silently "fixed" during the port.
URL string `json:"url"`
}
Current mirrors SharedChangelogData's `current` field.
type Data ¶
type Data struct {
Current Current `json:"current"`
ExpiresAt int64 `json:"expiresAt"`
Latest *Latest `json:"latest,omitempty"`
Packages *bool `json:"packages,omitempty"`
}
Data mirrors client/js/types/changelog.ts's SharedChangelogData. Packages is always nil - it fed the npm-outdated-package check in the dropped packages plugin system (see internal/themes's doc comment on that decision) and has no Go equivalent.