juju: github.com/juju/juju/worker Index | Files | Directories

package worker

import "github.com/juju/juju/worker"

Index

Package Files

errors.go finishedworker.go noopworker.go periodicworker.go runner.go simpleworker.go

Constants

const RestartDelay = 3 * time.Second

RestartDelay holds the length of time that a worker will wait between exiting and restarting.

Variables

var (
    ErrRestartAgent    = errors.New("agent should be restarted")
    ErrTerminateAgent  = errors.New("agent should be terminated")
    ErrRebootMachine   = errors.New("machine needs to reboot")
    ErrShutdownMachine = errors.New("machine needs to shutdown")
)

These errors are returned by various specific workers in the hope that they will have some specific effect on the top-level agent running that worker.

It should be clear that they don't belong here, and certainly shouldn't be used as they are today: e.g. a uniter has *no fricking idea* whether its host agent should shut down. A uniter can return ErrUnitDead, and its host might need to respond to that, perhaps by returning an error specific to *its* host; depending on these values punching right through N layers (but only when we want them to!) is kinda terrible.

var ErrKilled = errors.New("worker killed")

ErrKilled can be returned by the PeriodicWorkerCall to signify that the function has returned as a result of a Stop() or Kill() signal and that the function was able to stop cleanly

func NewNoOpWorker Uses

func NewNoOpWorker() worker.Worker

func NewPeriodicWorker Uses

func NewPeriodicWorker(call PeriodicWorkerCall, period time.Duration, timerFunc NewTimerFunc, options ...PeriodicWorkerOption) worker.Worker

NewPeriodicWorker returns a worker that runs the given function continually sleeping for sleepDuration in between each call, until Kill() is called The stopCh argument will be closed when the worker is killed. The error returned by the doWork function will be returned by the worker's Wait function.

func NewSimpleWorker Uses

func NewSimpleWorker(doWork func(stopCh <-chan struct{}) error) worker.Worker

NewSimpleWorker returns a worker that runs the given function. The stopCh argument will be closed when the worker is killed. The error returned by the doWork function will be returned by the worker's Wait function.

type FinishedWorker Uses

type FinishedWorker struct{}

FinishedWorker is a worker that stops immediately with no error when started by a Runner, which then removes it from the list of workers without restarting it. Simply return FinishedWorker{} where you need to avoid starting a worker at all.

func (FinishedWorker) Kill Uses

func (w FinishedWorker) Kill()

Kill implements Worker.Kill() and does nothing.

func (FinishedWorker) Wait Uses

func (w FinishedWorker) Wait() error

Wait implements Worker.Wait() and immediately returns no error.

type NewTimerFunc Uses

type NewTimerFunc func(time.Duration) PeriodicTimer

NewTimerFunc is a constructor used to obtain the instance of PeriodicTimer periodicWorker uses on its loop. TODO(fwereade): 2016-03-17 lp:1558657

type PeriodicTimer Uses

type PeriodicTimer interface {
    // Reset changes the timer to expire after duration d.
    // It returns true if the timer had been active, false
    // if the timer had expired or been stopped.
    Reset(time.Duration) bool
    // CountDown returns the channel used to signal expiration of
    // the timer duration. The channel is called C in the base
    // implementation of timer but the name is confusing.
    CountDown() <-chan time.Time
}

PeriodicTimer is an interface for the timer that periodicworker will use to handle the calls.

func NewTimer Uses

func NewTimer(d time.Duration) PeriodicTimer

NewTimer is the default implementation of NewTimerFunc.

type PeriodicWorkerCall Uses

type PeriodicWorkerCall func(stop <-chan struct{}) error

PeriodicWorkerCall represents the callable to be passed to the periodic worker to be run every elapsed period.

type PeriodicWorkerOption Uses

type PeriodicWorkerOption func(w *periodicWorker)

PeriodicWorkerOption is an optional parameter of the NewPeriodicWorker function and can be used to set optional parameters of the new periodic worker.

func Jitter Uses

func Jitter(amount float64) PeriodicWorkerOption

Jitter will introduce a jitter in the worker's period by the specified amount (as percents - i.e. between 0 and 1).

type Runner Uses

type Runner interface {
    worker.Worker
    StartWorker(id string, startFunc func() (worker.Worker, error)) error
    StopWorker(id string) error
}

Runner is implemented by instances capable of starting and stopping workers.

type Timer Uses

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

Timer implements PeriodicTimer.

func (*Timer) CountDown Uses

func (t *Timer) CountDown() <-chan time.Time

CountDown implements PeriodicTimer.

func (*Timer) Reset Uses

func (t *Timer) Reset(d time.Duration) bool

Reset implements PeriodicTimer.

Directories

PathSynopsis
actionpruner
agent
agentconfigupdater
apiaddressupdater
apicaller
apiconfigwatcher
apiserver
apiservercertwatcher
applicationscaler
auditconfigupdater
authenticationworker
caasbroker
caasenvironupgrader
caasfirewaller
caasoperator
caasoperator/mocksPackage mocks is a generated GoMock package.
caasoperatorprovisioner
caasoperator/remotestate
caasunitinit
caasunitprovisioner
caasupgrader
centralhub
certupdater
charmrevision
charmrevision/charmrevisionmanifold
cleaner
common
common/charmrunner
containerbroker
containerbroker/mocksPackage mocks is a generated GoMock package.
controller
controllerport
conv2state
credentialvalidator
deployer
diskmanagerPackage diskmanager defines a worker that periodically lists block devices on the machine it runs on.
environ
externalcontrollerupdater
fanconfigurer
featureflag
firewaller
fortressPackage fortress implements a convenient metaphor for an RWLock.
gatepackage gate provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.
globalclockupdater
hostkeyreporter
httpserver
httpserverargs
identityfilewriter
instancemutater
instancemutater/mocksPackage mocks is a generated GoMock package.
instancepoller
instancepoller/mocksPackage mocks is a generated GoMock package.
introspectionPackage introspection defines the worker that can report internal agent state through the use of a machine local socket.
introspection/pprofPackage pprof is a fork of net/http/pprof modified to communicate over a unix socket.
leadership
lease
lease/manifold
lifeflag
logforwarder
logforwarder/sinks
logger
logsender
logsender/logsendermetrics
logsender/logsendertestPackage logsendertest provides testing utilities related to the logsender package.
machineactions
machiner
machineundertaker
meterstatusPackage meterstatus provides a worker that executes the meter-status-changed hook periodically.
metrics/collectPackage collect provides a worker that executes the collect-metrics hook periodically, as long as the workload has been started (between start and stop hooks).
metrics/senderPackage sender contains the implementation of the metric sender manifold.
metrics/spoolPackage spool contains the implementation of a worker that extracts the spool directory path from the agent config and enables other workers to write and read metrics to and from a the spool directory using a writer and a reader.
metricworker
migrationflag
migrationmaster
migrationminion
minunitsworker
mocksPackage mocks is a generated GoMock package.
modelcache
modelupgrader
modelworkermanager
peergrouper
presence
provisioner
provisioner/mocksPackage mocks is a generated GoMock package.
proxyupdater
pruner
pubsub
raft
raft/raftbackstop
raft/raftclusterer
raft/raftflag
raft/raftforwarder
raft/rafttest
raft/rafttransport
raft/raftutil
reboot
remoterelations
restorewatcher
resumer
retrystrategy
singular
state
stateconfigwatcher
statushistorypruner
storageprovisionerPackage storageprovisioner provides a worker that manages the provisioning and deprovisioning of storage volumes and filesystems, and attaching them to and detaching them from machines.
storageprovisioner/internal/schedule
terminationworker
toolsversionchecker
txnpruner
undertaker
unitassigner
uniter
uniter/actions
uniter/charm
uniter/hookPackage hook provides types that define the hooks known to the Uniter
uniter/leadership
uniter/operation
uniter/operation/mocksPackage mocks is a generated GoMock package.
uniter/relationrelation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
uniter/remotestate
uniter/resolver
uniter/runcommands
uniter/runner
uniter/runner/contextPackage context contains the ContextFactory and Context definitions.
uniter/runner/debug
uniter/runner/jujucThe worker/uniter/runner/jujuc package implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.
uniter/runner/jujuc/jujuctesting
uniter/runner/testing
uniter/storagePackage storage contains the storage subsystem for the uniter, responding to changes in storage attachments (lifecycle, volume/filesystem details) by queuing hooks and managing the storage attachments' lifecycle.
uniter/upgradeseries
upgradedatabase
upgradedatabase/mocksPackage mocks is a generated GoMock package.
upgrader
upgradeseries
upgradeseries/mocksPackage mocks is a generated GoMock package.
upgradesteps

Package worker imports 6 packages (graph) and is imported by 2156 packages. Updated 2019-12-14. Refresh now. Tools for package owners.