worker

package
v0.0.0-...-23dbee4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const RestartDelay = 3 * time.Second

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

Variables

View Source
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.

View Source
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

Functions

func NewPeriodicWorker

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

func NewSimpleWorker(doWork func(context.Context) 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.

func NoopWorker

func NoopWorker() worker.Worker

NoopWorker returns a worker that waits for the context to be done.

Types

type FinishedWorker

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

func (w FinishedWorker) Kill()

Kill implements Worker.Kill() and does nothing.

func (FinishedWorker) Wait

func (w FinishedWorker) Wait() error

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

type NewTimerFunc

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

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

func NewTimer(d time.Duration) PeriodicTimer

NewTimer is the default implementation of NewTimerFunc.

type PeriodicWorkerCall

type PeriodicWorkerCall func(context.Context) error

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

type PeriodicWorkerOption

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

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

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

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

Timer implements PeriodicTimer.

func (*Timer) CountDown

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

CountDown implements PeriodicTimer.

func (*Timer) Reset

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

Reset implements PeriodicTimer.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package bootstrap ensures that when the initial bootstrap process has started that we seed the following:
Package bootstrap ensures that when the initial bootstrap process has started that we seed the following:
Package caasadmission defines the caasadmission worker.
Package caasadmission defines the caasadmission worker.
Package caasapplicationprovisioner defines two types of worker:
Package caasapplicationprovisioner defines two types of worker:
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package charmrevision defines the charm revision updater worker.
Package charmrevision defines the charm revision updater worker.
Package computeprovisioner defines the compute provisioner worker.
Package computeprovisioner defines the compute provisioner worker.
Package containerbroker worker sole responsibility is to manage the lifecycle of a instance-broker.
Package containerbroker worker sole responsibility is to manage the lifecycle of a instance-broker.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package containerprovisioner defines the container provisioner worker.
Package containerprovisioner defines the container provisioner worker.
Package controlleragentconfig provides a worker that listens on the "/reload" endpoint of the config change socket and restarts any workers that have requested to watch the config.
Package controlleragentconfig provides a worker that listens on the "/reload" endpoint of the config change socket and restarts any workers that have requested to watch the config.
Package controlsocket defines the controlsocket worker, which exposes a Unix socket that the juju-controller charm can use to affect Juju state.
Package controlsocket defines the controlsocket worker, which exposes a Unix socket that the juju-controller charm can use to affect Juju state.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package diskmanager defines a worker that periodically lists block devices on the machine it runs on.
Package diskmanager defines a worker that periodically lists block devices on the machine it runs on.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package fortress implements a convenient metaphor for an RWLock.
Package fortress implements a convenient metaphor for an RWLock.
Package gate provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.
Package gate provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.
Package httpclient provides a worker that manages http clients.
Package httpclient provides a worker that manages http clients.
Package instancemutater defines workers that compares the list of lxd profiles applied to a machine with the list of expected profiles based on the application versions which should be running on the machine.
Package instancemutater defines workers that compares the list of lxd profiles applied to a machine with the list of expected profiles based on the application versions which should be running on the machine.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package introspection defines the worker that can report internal agent state through the use of a machine local socket.
Package introspection defines the worker that can report internal agent state through the use of a machine local socket.
pprof
Package pprof is a fork of net/http/pprof modified to communicate over a unix socket.
Package pprof is a fork of net/http/pprof modified to communicate over a unix socket.
Package lease, also known as the manager, manages the leases used by individual Juju workers.
Package lease, also known as the manager, manages the leases used by individual Juju workers.
logsendertest
Package logsendertest provides testing utilities related to the logsender package.
Package logsendertest provides testing utilities related to the logsender package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package remoterelations defines workers which manage the operation of cross model relations.
Package remoterelations defines workers which manage the operation of cross model relations.
Package secretbackendrotate provides a worker for tracking and rotating a secret backend token.
Package secretbackendrotate provides a worker for tracking and rotating a secret backend token.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package secretexpire provides a worker for tracking and notifying when a secret revision should expire.
Package secretexpire provides a worker for tracking and notifying when a secret revision should expire.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package secretrotate provides a worker for tracking and notifying when a secret should be rotated.
Package secretrotate provides a worker for tracking and notifying when a secret should be rotated.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package secretsdrainworker provides a worker running on the agent for draining secrets to the new active backend when the model changed secret backend.
Package secretsdrainworker provides a worker running on the agent for draining secrets to the new active backend when the model changed secret backend.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package secretspruner provides a worker for tracking and pruning when a user supplied secret revision is obsolote.
Package secretspruner provides a worker for tracking and pruning when a user supplied secret revision is obsolote.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package simplesignalhandler provides a worker that responds to os signals and returns a pre-defined error from this worker when the signal is received.
Package simplesignalhandler provides a worker that responds to os signals and returns a pre-defined error from this worker when the signal is received.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package storageprovisioner provides a worker that manages the provisioning and deprovisioning of storage volumes and filesystems, and attaching them to and detaching them from machines.
Package storageprovisioner provides a worker that manages the provisioning and deprovisioning of storage volumes and filesystems, and attaching them to and detaching them from machines.
Package uniter is the "uniter" worker which implements the capabilities of the unit agent, for example running a charm's hooks in response to model events.
Package uniter is the "uniter" worker which implements the capabilities of the unit agent, for example running a charm's hooks in response to model events.
api
Package api defines the api client interfaces used by the uniter and the gomock mocks used in testing.
Package api defines the api client interfaces used by the uniter and the gomock mocks used in testing.
charm/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
hook
Package hook provides types that define the hooks known to the Uniter.
Package hook provides types that define the hooks known to the Uniter.
operation/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
relation
Package relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
Package relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
relation/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
runner/context
Package context contains the ContextFactory and Context definitions.
Package context contains the ContextFactory and Context definitions.
runner/context/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
runner/jujuc
Package jujuc 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.
Package jujuc 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.
runner/jujuc/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
runner/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
secrets/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
storage
Package 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.
Package 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.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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