Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionIsDead = func(logger loggo.Logger, conn Breakable) bool {
	return conn.IsBroken()
}

ConnectionIsDead returns true if the given Breakable is broken.

View Source
var PingerIsDead = func(logger loggo.Logger, conn Pinger) bool {
	if err := conn.Ping(); err != nil {
		logger.Infof("error pinging %T: %v", conn, err)
		return true
	}
	return false
}

PingerIsDead returns true if the given pinger fails to ping.

Functions

func ConnectionIsFatal

func ConnectionIsFatal(logger loggo.Logger, conns ...Breakable) func(err error) bool

ConnectionIsFatal returns a function suitable for passing as the isFatal argument to worker.NewRunner, that diagnoses an error as fatal if the connection has failed or if the error is otherwise fatal.

func IsFatal

func IsFatal(err error) bool

IsFatal determines if an error is fatal to the process.

func MoreImportant

func MoreImportant(err0, err1 error) bool

MoreImportant returns whether err0 is more important than err1 - that is, whether we should act on err0 in preference to err1.

func MoreImportantError

func MoreImportantError(err0, err1 error) error

MoreImportantError returns the most important error

func PingerIsFatal

func PingerIsFatal(logger loggo.Logger, conns ...Pinger) func(err error) bool

PingerIsFatal returns a function suitable for passing as the isFatal argument to worker.NewRunner, that diagnoses an error as fatal if the Pinger has failed or if the error is otherwise fatal.

TODO(mjs) - this only exists for checking State instances in the machine agent and won't be necessary once either: 1. State grows a Broken() channel like api.Connection (which is

actually quite a nice idea).

2. The dependency engine conversion is completed for the machine

agent.

func RequiredError

func RequiredError(name string) error

RequiredError is useful when complaining about missing command-line options.

Types

type Breakable

type Breakable interface {
	IsBroken() bool
}

Breakable provides a type that exposes an IsBroken check.

type FatalError

type FatalError struct {
	Err string
}

FatalError is an error type designated for fatal errors.

func (*FatalError) Error

func (e *FatalError) Error() string

Error returns an error string.

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger represents the logging methods used by this package.

type Pinger

type Pinger interface {
	Ping() error
}

Pinger provides a type that knows how to ping.

type UpgradeReadyError

type UpgradeReadyError struct {
	AgentName string
	OldTools  version.Binary
	NewTools  version.Binary
	DataDir   string
}

UpgradeReadyError is returned by an Upgrader to report that an upgrade is ready to be performed and a restart is due.

func (*UpgradeReadyError) ChangeAgentTools

func (e *UpgradeReadyError) ChangeAgentTools(logger Logger) error

ChangeAgentTools does the actual agent upgrade. It should be called just before an agent exits, so that it will restart running the new tools.

func (*UpgradeReadyError) Error

func (e *UpgradeReadyError) Error() string

Source Files