Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDead = errors.New("worker runner is not running")
var ErrTerminateAgent = errors.New("agent should be terminated")
var RestartDelay = 3 * time.Second
RestartDelay holds the length of time that a worker will wait between exiting and restarting.
Functions ¶
func WaitForEnviron ¶
func WaitForEnviron(w apiwatcher.NotifyWatcher, st EnvironConfigGetter, dying <-chan struct{}) (environs.Environ, error)
WaitForEnviron waits for an valid environment to arrive from the given watcher. It terminates with tomb.ErrDying if it receives a value on dying.
Types ¶
type EnvironConfigGetter ¶
EnvironConfigGetter interface defines a way to read the environment configuration.
type NotifyWatchHandler ¶
type NotifyWatchHandler interface { // SetUp starts the handler, this should create the watcher we // will be waiting on for more events. SetUp can return a Watcher // even if there is an error, and the notify Worker will make sure // to stop the watcher. SetUp() (apiWatcher.NotifyWatcher, error) // TearDown should cleanup any resources that are left around TearDown() error // Handle is called when the Watcher has indicated there are // changes, do whatever work is necessary to process it Handle() error }
NotifyWatchHandler implements the business logic that is triggered as part of watching a NotifyWatcher.
type Runner ¶
type Runner interface { Worker StartWorker(id string, startFunc func() (Worker, error)) error StopWorker(id string) error }
Runner is implemented by instances capable of starting and stopping workers.
func NewRunner ¶
NewRunner creates a new Runner. When a worker finishes, if its error is deemed fatal (determined by calling isFatal), all the other workers will be stopped and the runner itself will finish. Of all the fatal errors returned by the stopped workers, only the most important one, determined by calling moreImportant, will be returned from Runner.Wait. Non-fatal errors will not be returned.
The function isFatal(err) returns whether err is a fatal error. The function moreImportant(err0, err1) returns whether err0 is considered more important than err1.
type StringsWatchHandler ¶
type StringsWatchHandler interface { // SetUp starts the handler, this should create the watcher we // will be waiting on for more events. SetUp can return a Watcher // even if there is an error, and strings Worker will make sure to // stop the watcher. SetUp() (apiWatcher.StringsWatcher, error) // TearDown should cleanup any resources that are left around TearDown() error // Handle is called when the Watcher has indicated there are // changes, do whatever work is necessary to process it Handle(changes []string) error }
StringsWatchHandler implements the business logic triggered as part of watching a StringsWatcher.
type Worker ¶
type Worker interface { // Kill asks the worker to stop without necessarily // waiting for it to do so. Kill() // Wait waits for the worker to exit and returns any // error encountered when it was running. Wait() error }
Worker is implemented by a running worker.
func NewNotifyWorker ¶
func NewNotifyWorker(handler NotifyWatchHandler) Worker
NewNotifyWorker starts a new worker running the business logic from the handler. The worker loop is started in another goroutine as a side effect of calling this.
func NewSimpleWorker ¶
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 NewStringsWorker ¶
func NewStringsWorker(handler StringsWatchHandler) Worker
NewStringsWorker starts a new worker running the business logic from the handler. The worker loop is started in another goroutine as a side effect of calling this.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
hook
hook provides types that define the hooks known to the Uniter
|
hook provides types that define the hooks known to the Uniter |
jujuc
The worker/uniter/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.
|
The worker/uniter/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. |
relation
relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
|
relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run. |