Documentation
¶
Overview ¶
Package selfcheck probes the reference targets of a node to tell whether the node itself has lost its connectivity (ADR 0022, FA-CON-04). A round counts as failed only when every target fails; a single reachable target proves that egress works.
Index ¶
Constants ¶
const ( DefaultInterval = 30 * time.Second DefaultTimeout = 5 * time.Second )
Defaults for Options fields that are left at their zero value (ADR 0022).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Targets []Target
Dialer *checker.Dialer
Interval time.Duration // default DefaultInterval
Timeout time.Duration // per target, default DefaultTimeout
Now func() time.Time
Logger *slog.Logger
}
Options configures a Prober. Dialer is required: it is the SSRF-aware dialer of the checkers, so self-checks obey the same address policy.
type Prober ¶
type Prober struct {
// contains filtered or unexported fields
}
Prober runs the reference targets periodically. Status may be called concurrently with Run.
type Remote ¶
type Remote struct {
Status Status
// ReceivedAt is the local time at which the answer arrived.
ReceivedAt time.Time
// Age is how old the round was when the peer answered, on the peer's clock.
Age time.Duration
}
Remote is the self-check state of a peer as the leader last received it through GetStatus (ADR 0022). Ages are kept apart from the clocks: the peer reports its own wall clock, so its round age does not depend on the skew.
type Status ¶
type Status struct {
// Configured is true when at least one target is configured.
Configured bool
// Failed is true when all targets failed in the latest round.
Failed bool
// AtMs is the Unix time in milliseconds of the latest completed round; 0
// before the first round.
AtMs int64
}
Status is the result of the latest completed round.
type Target ¶
type Target struct {
// Label is the log-safe form: host:port for TCP, scheme://host[:port] for
// HTTP. It never contains a path or query.
Label string
// Addr is host:port of a TCP target; empty for HTTP targets.
Addr string
// URL is the http(s) URL that is sent a HEAD request; empty for TCP targets.
URL string
}
Target is one parsed reference target.
func ParseTargets ¶
ParseTargets parses SELF_CHECK_TARGETS entries. Each entry is either host:port (TCP connect) or an http(s) URL (HTTP HEAD). Blank entries are skipped. All invalid entries are reported together; each error names its entry.