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)

New starts a new model worker manager.

Types

type Config

type Config struct {
	Authority      pki.Authority
	Clock          clock.Clock
	Logger         Logger
	MachineID      string
	ModelWatcher   ModelWatcher
	Mux            *apiserverhttp.Mux
	Controller     Controller
	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 Controller

type Controller interface {
	Config() (controller.Config, error)
	Model(modelUUID string) (Model, func(), error)
	DBLogger(modelUUID string) (DBLogger, error)
}

Controller provides an interface for getting models by UUID, and other details needed to pass into the function to start workers for a model. Once a model is no longer required, the returned function must be called to dispose of the model.

type DBLogger

type DBLogger interface {
	// Log writes the given log records to the logger's storage.
	Log([]state.LogRecord) error
	Close()
}

DBLogger writes into the log collections.

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Warningf(string, ...interface{})
}

Logger defines the logging methods used by the worker.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName      string
	AuthorityName  string
	StateName      string
	Clock          clock.Clock
	MuxName        string
	NewWorker      func(Config) (worker.Worker, error)
	NewModelWorker NewModelWorkerFunc
	Logger         Logger
}

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
	Name() string
	Owner() names.UserTag
}

Model represents a model.

type ModelLogger

type ModelLogger interface {
	loggo.Writer
	Close() error
}

ModelLogger is a database backed loggo Writer.

type ModelWatcher

type ModelWatcher interface {
	WatchModels() state.StringsWatcher
}

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

type NewModelConfig

type NewModelConfig struct {
	Authority        pki.Authority
	ModelName        string // Use a fully qualified name "<namespace>-<name>"
	ModelUUID        string
	ModelType        state.ModelType
	ModelLogger      ModelLogger
	Mux              *apiserverhttp.Mux
	ControllerConfig controller.Config
}

NewModelConfig holds the information required by the NewModelWorkerFunc to start the workers for the specified model

type NewModelWorkerFunc

type NewModelWorkerFunc func(config NewModelConfig) (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 StatePoolController

type StatePoolController struct {
	*state.StatePool
}

StatePoolController implements Controller in terms of a *state.StatePool.

func (StatePoolController) Config

Config is part of the Controller interface.

func (StatePoolController) DBLogger

func (g StatePoolController) DBLogger(modelUUID string) (DBLogger, error)

DBLogger returns a database logger for the specified model.

func (StatePoolController) Model

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

Model is part of the Controller interface.