modelworkermanager

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2017 Canonical Ltd. Licensed under the AGPLv3, see LICENCE file for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a model worker manager.

func New

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

Types

type Config

type Config struct {
	ModelWatcher   ModelWatcher
	ModelGetter    ModelGetter
	NewModelWorker NewModelWorkerFunc
	ErrorDelay     time.Duration
}

Config holds the dependencies and configuration necessary to run a model worker manager.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if config cannot be expected to drive a functional model worker manager.

type ManifoldConfig

type ManifoldConfig struct {
	StateName      string
	NewWorker      func(Config) (worker.Worker, error)
	NewModelWorker NewModelWorkerFunc
}

ManifoldConfig holds the information necessary to run a model worker manager in a dependency.Engine.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type Model

type Model interface {
	MigrationMode() state.MigrationMode
	Type() state.ModelType
}

Model represents a model.

type ModelGetter

type ModelGetter interface {
	Model(modelUUID string) (Model, func(), error)
}

ModelGetter provides an interface for getting models by UUID. Once a model is no longer required, the returned function must be called to dispose of the model.

type ModelWatcher

type ModelWatcher interface {
	WatchModels() state.StringsWatcher
}

ModelWatcher provides an interface for watching the additiona and removal of models.

type NewModelWorkerFunc

type NewModelWorkerFunc func(modelUUID string, modelType state.ModelType) (worker.Worker, error)

NewModelWorkerFunc should return a worker responsible for running all a model's required workers; and for returning nil when there's no more model to manage.

type StatePoolModelGetter

type StatePoolModelGetter struct {
	*state.StatePool
}

StatePoolModelGetter implements ModelGetter in terms of a *state.StatePool.

func (StatePoolModelGetter) Model

func (g StatePoolModelGetter) Model(modelUUID string) (Model, func(), error)

Model is part of the ModelGetter interface.

Jump to

Keyboard shortcuts

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