Documentation
¶
Overview ¶
Package schedule is what an agent reports of how often each set it writes gets a snapshot, and when a store counts a set late by that.
Index ¶
Constants ¶
const ( Every = "every" Cron = "cron" Receiver = "receiver" )
The kinds of plan a set's snapshots follow: an interval, a cron expression, or a receiver of a database's log, which commits only while the database writes.
const ( ReportEvery = 24 * time.Hour SilentAfter = 48 * time.Hour StaleAfter = 30 * 24 * time.Hour )
An agent reports every ReportEvery. It is silent once its report is SilentAfter overdue, and what it reported expires StaleAfter after its last report.
Variables ¶
var ErrInvalid = errors.New("invalid schedule")
ErrInvalid is an Expectation no plan makes.
Functions ¶
Types ¶
type Expectation ¶
type Expectation struct {
Set string
Kind string
// LongestGap is the most time the plan allows between two snapshots;
// zero for a Receiver.
LongestGap time.Duration
// Jitter is the window the plan's slots move by.
Jitter time.Duration
// CommitEvery is how often a Receiver commits while its database
// writes.
CommitEvery time.Duration
}
Expectation is how often one set gets a snapshot by its agent's plan.
func (Expectation) Validate ¶
func (e Expectation) Validate() error
Validate reports an Expectation without a set, of an unknown kind, with a negative duration, or without the gap or commit interval its kind takes, as ErrInvalid.
type Report ¶
type Report struct {
Agent string
Sets []Expectation
}
Report is what an agent plans: an Expectation per set it writes. It replaces what the agent reported before, so a set it no longer lists expects nothing.
type Reported ¶
Reported is the Expectation a store keeps for a set: the last one an agent reported, the agent, since when that agent reports the set and when it last did.
func (Reported) Late ¶
Late reports whether the set is late at now, given when the store received its newest snapshot, zero for none: once its agent is Silent, whatever that snapshot, and otherwise, but for a Receiver, once its LongestGap, Jitter and Grace passed since that snapshot, or since r's agent first reported the set if that is later. A Stale r is never late.