This section is empty.


View Source
var ErrChanged = errors.New("migration flag value changed")

ErrChanged indicates that a Worker has stopped because its Check result is no longer valid.


func IsTerminal

func IsTerminal(phase migration.Phase) bool

IsTerminal returns true when the given phase means a migration has finished (successfully or otherwise).

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold packages a Worker for use in a dependency.Engine.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

NewWorker creates a *Worker and returns it as a worker.Worker.


type Config

type Config struct {
	Facade Facade
	Model  string
	Check  Predicate

Config holds the dependencies and configuration for a Worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be expected to drive a functional Worker.

type Facade

type Facade interface {
	Watch(uuid string) (watcher.NotifyWatcher, error)
	Phase(uuid string) (migration.Phase, error)

Facade exposes controller functionality required by a Worker.

func NewFacade

func NewFacade(apiCaller base.APICaller) (Facade, error)

NewFacade creates a *migrationflag.Facade and returns it as a Facade.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	Check         Predicate

	NewFacade func(base.APICaller) (Facade, error)
	NewWorker func(Config) (worker.Worker, error)

ManifoldConfig holds the dependencies and configuration for a Worker manifold.

type Predicate

type Predicate func(migration.Phase) bool

Predicate defines a predicate.

type Worker

type Worker struct {
	// contains filtered or unexported fields

Worker implements worker.Worker and util.Flag, and exits with ErrChanged whenever the result of its configured Check of the Model's migration phase changes.

func New

func New(config Config) (*Worker, error)

New returns a Worker that tracks the result of the configured Check on the Model's migration phase, as exposed by the Facade.

func (*Worker) Check

func (w *Worker) Check() bool

Check is part of the util.Flag interface.

func (*Worker) Kill

func (w *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Wait

func (w *Worker) Wait() error

Wait is part of the worker.Worker interface.