Documentation
¶
Overview ¶
Package updatecheck looks up the latest RD Panel release on GitHub for the About page. Answers are cached (6 h by default; failures are retried after 30 min while the last good answer is kept), so the panel calls the GitHub API at most a few times a day no matter how often the page is opened.
Index ¶
Constants ¶
View Source
const ( DefaultTTL = 6 * time.Hour DefaultRetry = 30 * time.Minute )
Defaults of a Checker.
View Source
const DefaultURL = "https://api.github.com/repos/bropines/rdpanel/releases/latest"
DefaultURL is the GitHub "latest release" endpoint of this project.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
URL string
UserAgent string
Client *http.Client
TTL time.Duration // cache lifetime of a successful answer
Retry time.Duration // delay before retrying after a failure
Now func() time.Time
// contains filtered or unexported fields
}
Checker fetches and caches the latest release. The zero value is not usable; use New.
type Release ¶
type Release struct {
Version string // tag name, e.g. "v0.2.0"
URL string // release page
PublishedAt time.Time
}
Release is a published GitHub release.
type Result ¶
type Result struct {
// Latest is nil until a check succeeded (or when the repository has no
// published release yet).
Latest *Release
// CheckedAt is the time of the last attempt.
CheckedAt time.Time
// Err is the last attempt's error ("" when it succeeded).
Err string
}
Result is the cached state of the check.
type Status ¶
type Status string
Status compares a running version with the latest release.
const ( StatusUnknown Status = "unknown" StatusUpToDate Status = "up_to_date" StatusUpdateAvailable Status = "update_available" )
Status values.
Click to show internal directories.
Click to hide internal directories.