util

package
v0.0.0-...-4bd6544 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataDir           = paths.MustSucceed(paths.DataDir(series.HostSeries()))
	EnsureMongoServer = mongo.EnsureServer
)
View Source
var ConnectionIsDead = 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
}

ConnectionIsDead returns true if the given pinger fails to ping.

Functions

func AgentDone

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

AgentDone processes the error returned by an exiting agent.

func ConnectionIsFatal

func ConnectionIsFatal(logger loggo.Logger, conns ...Pinger) 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 NewCloseWorker

func NewCloseWorker(logger loggo.Logger, worker worker.Worker, closer io.Closer) worker.Worker

NewCloseWorker returns a task that wraps the given task, closing the given closer when it finishes.

func NewEnsureServerParams

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

NewEnsureServerParams creates an EnsureServerParams from an agent configuration.

func ParamsStateServingInfoToStateStateServingInfo

func ParamsStateServingInfoToStateStateServingInfo(i params.StateServingInfo) state.StateServingInfo

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

func RequiredError

func RequiredError(name string) error

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

Types

type CloseWorker

type CloseWorker struct {
	// contains filtered or unexported fields
}

CloseWorker is a worker which closes the given closer when finished with a task.

func (*CloseWorker) Kill

func (c *CloseWorker) Kill()

func (*CloseWorker) Wait

func (c *CloseWorker) Wait() error

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 Pinger

type Pinger interface {

	// Ping pings something.
	Ping() error
}

Pinger provides a type that knows how to ping.

Jump to

Keyboard shortcuts

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