juju: github.com/juju/juju/apiserver/facades/agent/presence Index | Files

package presence

import "github.com/juju/juju/apiserver/facades/agent/presence"


Package Files


type Config Uses

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 Uses

func (config Config) Validate() error

Validate returns an error if Config cannot be expected to drive a Worker.

type Pinger Uses

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 Uses

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 Uses

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 Uses

func (w *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Stop Uses

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 Uses

func (w *Worker) Wait() error

Wait is part of the worker.Worker interface.

Package presence imports 8 packages (graph) and is imported by 4 packages. Updated 2019-09-01. Refresh now. Tools for package owners.