Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrHashMismatch = errors.New("new file hash mismatch after patch") ErrInvalidHash = errors.New("invalid hash in update info") ErrChannelMismatch = errors.New("update channel mismatch") ErrNoRequester = errors.New("no HTTP requester configured") )
Common errors
Functions ¶
This section is empty.
Types ¶
type DailyScheduler ¶
type DailyScheduler struct {
// contains filtered or unexported fields
}
DailyScheduler implements UpdateScheduler for updates at a specific hour
func NewDailyScheduler ¶
func NewDailyScheduler(hour int) *DailyScheduler
NewDailyScheduler creates a scheduler that runs once per day at the specified hour
func (*DailyScheduler) NextUpdate ¶
func (s *DailyScheduler) NextUpdate() time.Time
func (*DailyScheduler) SetNextUpdate ¶
func (s *DailyScheduler) SetNextUpdate()
func (*DailyScheduler) ShouldUpdate ¶
func (s *DailyScheduler) ShouldUpdate(currentVersion string, forceCheck bool) bool
type HTTPRequester ¶
type HTTPRequester struct{}
HTTPRequester is the normal requester that is used and does an HTTP to the URL location requested to retrieve the specified data.
func (*HTTPRequester) Fetch ¶
func (httpRequester *HTTPRequester) Fetch(url string) (io.ReadCloser, error)
Fetch will return an HTTP request to the specified url and return the body of the result. An error will occur for a non 200 status code.
type IntervalScheduler ¶
type IntervalScheduler struct {
// contains filtered or unexported fields
}
IntervalScheduler implements UpdateScheduler for updates at fixed intervals
func NewIntervalScheduler ¶
func NewIntervalScheduler(checkTime, randomizeTime int) *IntervalScheduler
NewIntervalScheduler creates a scheduler that runs at fixed intervals with optional randomization
func (*IntervalScheduler) NextUpdate ¶
func (s *IntervalScheduler) NextUpdate() time.Time
func (*IntervalScheduler) SetNextUpdate ¶
func (s *IntervalScheduler) SetNextUpdate()
func (*IntervalScheduler) ShouldUpdate ¶
func (s *IntervalScheduler) ShouldUpdate(currentVersion string, forceCheck bool) bool
type Requester ¶
type Requester interface {
Fetch(url string) (io.ReadCloser, error)
}
Requester interface allows developers to customize the method in which requests are made to retrieve the version and binary.
type UpdateInfo ¶
UpdateInfo contains metadata about an available update
type UpdateScheduler ¶
type UpdateScheduler interface { // ShouldUpdate returns true if an update should be performed now ShouldUpdate(currentVersion string, forceCheck bool) bool // SetNextUpdate schedules the next update time SetNextUpdate() // NextUpdate returns when the next update is scheduled NextUpdate() time.Time }
UpdateScheduler defines how update timing is handled
type Updater ¶
type Updater struct { CurrentVersion string ApiURL string CmdName string BinURL string DiffURL string Dir string ForceCheck bool Scheduler UpdateScheduler Requester Requester Channel string Info UpdateInfo OnSuccessfulUpdate func() }
Updater handles the self-update process
func (*Updater) NextUpdate ¶
func (*Updater) UpdateIfNeeded ¶
UpdateIfNeeded starts the update check and apply cycle