presence

package
v0.0.0-...-8ff1004 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 8 Imported by: 0

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.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if Config cannot be expected 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

func New(config Config) (*Worker, error)

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.

func (*Worker) Kill

func (w *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Stop

func (w *Worker) Stop() error

Stop is part of the apiserver/common.Resource interface.

It's not a very good idea -- see comments on lp:1572237 -- but we're only addressing the proximate cause of the issue here.

func (*Worker) Wait

func (w *Worker) Wait() error

Wait is part of the worker.Worker interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL