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

package gate

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

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.

Index

Package Files

flag.go interface.go manifold.go shim.go

Variables

var ErrUnlocked = errors.New("gate unlocked")

ErrUnlocked indicates that a Flag's gate has been unlocked and it should be restarted to reflect the new value.

func FlagManifold Uses

func FlagManifold(config FlagManifoldConfig) dependency.Manifold

FlagManifold runs a worker that implements engine.Flag such that it's only considered set when the referenced gate is unlocked.

func Manifold Uses

func Manifold() dependency.Manifold

Manifold returns a dependency.Manifold that wraps a single channel, shared across all workers returned by the start func; it can be used to synchronize operations across manifolds that lack direct dependency relationships.

The output func accepts an out pointer to either an Unlocker or a Waiter.

func ManifoldEx Uses

func ManifoldEx(lock Lock) dependency.Manifold

ManifoldEx does the same thing as Manifold but takes the Lock which used to wait on or unlock the gate. This allows code running outside of a dependency engine managed worker to monitor or unlock the gate.

TODO(mjs) - this can likely go away once all machine agent workers are running inside the dependency engine.

func NewFlagWorker Uses

func NewFlagWorker(gate Waiter) (worker.Worker, error)

type AlreadyUnlocked Uses

type AlreadyUnlocked struct{}

AlreadyUnlocked is a Waiter that always reports its gate to be unlocked.

func (AlreadyUnlocked) IsUnlocked Uses

func (AlreadyUnlocked) IsUnlocked() bool

IsUnlocked is part of the Waiter interface.

func (AlreadyUnlocked) Unlocked Uses

func (AlreadyUnlocked) Unlocked() <-chan struct{}

Unlocked is part of the Waiter interface.

type Flag Uses

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

Flag uses a gate to implement engine.Flag.

func NewFlag Uses

func NewFlag(gate Waiter) (*Flag, error)

NewFlag returns a worker that implements engine.Flag, backed by the supplied gate's unlockedness.

func (*Flag) Check Uses

func (w *Flag) Check() bool

Check is part of the engine.Flag interface.

func (*Flag) Kill Uses

func (w *Flag) Kill()

Kill is part of the worker.Worker interface.

func (*Flag) Wait Uses

func (w *Flag) Wait() error

Wait is part of the worker.Worker interface.

type FlagManifoldConfig Uses

type FlagManifoldConfig struct {
    GateName  string
    NewWorker func(gate Waiter) (worker.Worker, error)
}

FlagManifoldConfig holds the dependencies required to run a Flag in a dependency.Engine.

type Lock Uses

type Lock interface {
    Waiter
    Unlocker
}

Lock combines the Waiter and Unlocker interfaces.

func NewLock Uses

func NewLock() Lock

NewLock returns a new Lock for the gate manifold, suitable for passing to ManifoldEx. It can be safely unlocked and monitored by code running inside or outside of the dependency engine.

type Unlocker Uses

type Unlocker interface {
    Unlock()
}

Unlocker is used to unlock a shared gate.

type Waiter Uses

type Waiter interface {
    Unlocked() <-chan struct{}
    IsUnlocked() bool
}

Waiter is used to wait for a shared gate to be unlocked.

Package gate imports 6 packages (graph) and is imported by 175 packages. Updated 2018-09-02. Refresh now. Tools for package owners.