juju: github.com/juju/juju/watcher/legacy Index | Files

package legacy

import "github.com/juju/juju/watcher/legacy"

Package legacy contains state-watcher-tuned worker harnesses; the canonical implementations are in the watcher package, but aren't type-compatible with original-style watchers -- such as those returned from state methods -- which we still have a couple of uses for (and the certupdater use might even be legitimate).

Index

Package Files

doc.go notifyworker.go stringsworker.go

func NewNotifyWorker Uses

func NewNotifyWorker(handler NotifyWatchHandler) worker.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 NewStringsWorker Uses

func NewStringsWorker(handler StringsWatchHandler) worker.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.

type NotifyWatchHandler Uses

type NotifyWatchHandler interface {
    // SetUp will be called once, and should return the watcher that will
    // be used to trigger subsequent Handle()s. SetUp can return a watcher
    // even if there is an error, and the notify worker will make sure
    // to stop the watcher.
    SetUp() (state.NotifyWatcher, error)

    // TearDown should cleanup any resources that are left around.
    TearDown() error

    // Handle is called whenever the watcher returned from SetUp sends a value
    // on its Changes() channel. The done channel will be closed if and when
    // the worker is being interrupted to finish. Any worker should avoid any
    // bare channel reads or writes, but instead use a select with the done
    // channel.
    Handle(done <-chan struct{}) error
}

NotifyWatchHandler implements the business logic that is triggered as part of watching a NotifyWatcher.

type StringsWatchHandler Uses

type StringsWatchHandler interface {
    // SetUp will be called once, and should return the watcher that will
    // be used to trigger subsequent Handle()s. SetUp can return a watcher
    // even if there is an error, and the notify worker will make sure
    // to stop the watcher.
    SetUp() (state.StringsWatcher, error)

    // TearDown should cleanup any resources that are left around.
    TearDown() error

    // Handle is called whenever the watcher returned from SetUp sends a value
    // on its Changes() channel.
    Handle(changes []string) error
}

StringsWatchHandler implements the business logic triggered as part of watching a StringsWatcher.

Package legacy imports 4 packages (graph) and is imported by 47 packages. Updated 2018-09-14. Refresh now. Tools for package owners.