juju: github.com/juju/juju/cmd/jujud/util Index | Files

package util

import "github.com/juju/juju/cmd/jujud/util"


Package Files



var (
    DataDir           = paths.MustSucceed(paths.DataDir(series.MustHostSeries()))
    LogDir            = paths.MustSucceed(paths.LogDir(series.MustHostSeries()))
    EnsureMongoServer = mongo.EnsureServer
var ConnectionIsDead = func(logger loggo.Logger, conn Breakable) bool {
    return conn.IsBroken()

ConnectionIsDead returns true if the given Breakable is broken.

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.

func AgentDone Uses

func AgentDone(logger loggo.Logger, err error) error

AgentDone processes the error returned by an exiting agent.

func ConnectionIsFatal Uses

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 Uses

func IsFatal(err error) bool

IsFatal determines if an error is fatal to the process.

func MoreImportant Uses

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 Uses

func MoreImportantError(err0, err1 error) error

MoreImportantError returns the most important error

func NewEnsureServerParams Uses

func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams, error)

NewEnsureServerParams creates an EnsureServerParams from an agent configuration.

func ParamsStateServingInfoToStateStateServingInfo Uses

func ParamsStateServingInfoToStateStateServingInfo(i params.StateServingInfo) state.StateServingInfo

ParamsStateServingInfoToStateStateServingInfo converts a params.StateServingInfo to a state.StateServingInfo.

func PingerIsFatal Uses

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


func RequiredError Uses

func RequiredError(name string) error

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

type Breakable Uses

type Breakable interface {
    IsBroken() bool

Breakable provides a type that exposes an IsBroken check.

type FatalError Uses

type FatalError struct {
    Err string

FatalError is an error type designated for fatal errors.

func (*FatalError) Error Uses

func (e *FatalError) Error() string

Error returns an error string.

type Pinger Uses

type Pinger interface {
    Ping() error

Pinger provides a type that knows how to ping.

Package util imports 12 packages (graph) and is imported by 184 packages. Updated 2019-10-30. Refresh now. Tools for package owners.