Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Identity records the entity whose connectedness is being // affirmed by this worker. It's used to create a logger that // can let us see which agent's pinger is actually failing. Identity names.Tag // Start starts a new, running Pinger or returns an error. Start func() (Pinger, error) // Clock is used to throttle failed Start attempts. Clock clock.Clock // RetryDelay controls by how much we throttle failed Start // attempts. Note that we only apply the delay when a Start // fails; if a Pinger ran, however briefly, we'll try to restart // it immediately, so as to minimise the changes of erroneously // causing agent-lost to be reported. RetryDelay time.Duration }
Config contains the information necessary to drive a Worker.
type Pinger ¶
type Pinger interface { // Stop kills the pinger, then waits for it to exit. Stop() error // Wait waits for the pinger to stop. Wait() error }
Pinger exposes some methods implemented by state/presence.Pinger.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker creates a Pinger as configured, and recreates it as it fails until the Worker is stopped; at which point it shuts down any extant Pinger before returning.
func New ¶
New returns a Worker backed by Config. The caller is responsible for Kill()ing the Worker and handling any errors returned from Wait(); but as it happens it's designed to be an apiserver/common.Resource, and never to exit unless Kill()ed, so in practice Stop(), which will call Kill() and Wait() internally, is Good Enough.
Click to show internal directories.
Click to hide internal directories.