environupgrader

package
v0.0.0-...-23dbee4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModelRemoved = errors.New("model has been removed")

ErrModelRemoved indicates that this worker was operating on the model that is no longer found.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a Worker as configured.

func NewWorker

func NewWorker(ctx context.Context, config Config) (worker.Worker, error)

NewWorker returns a worker that ensures that environ/provider schema upgrades are run when the model is first loaded by a controller of a new version. The worker either runs the upgrades or waits for another controller unit to run them, depending on the configuration.

Types

type Config

type Config struct {
	// Facade holds the API facade used by this worker for getting,
	// setting and watching the model's environ version.
	Facade Facade

	// GateUnlocker holds a gate.Unlocker that the worker must call
	// after the model has been successfully upgraded.
	GateUnlocker gate.Unlocker

	// ControllerTag holds the tag of the controller that runs this
	// worker.
	ControllerTag names.ControllerTag

	// ModelTag holds the tag of the model to which this worker is
	// scoped.
	ModelTag names.ModelTag

	// Environ holds the Environ used to run upgrade steps, or nil
	// if the worker should wait for upgrade steps to be run by
	// another agent.
	Environ environs.Environ

	// CredentialAPI holds the API facade used to invalidate credential
	// whenever the worker makes cloud calls if credential for this model
	// becomes invalid.
	CredentialAPI common.CredentialAPI

	Logger logger.Logger
}

Config holds the configuration and dependencies 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 {
	ModelEnvironVersion(ctx context.Context, tag names.ModelTag) (int, error)
	ModelTargetEnvironVersion(ctx context.Context, tag names.ModelTag) (int, error)
	SetModelEnvironVersion(ctx context.Context, tag names.ModelTag, v int) error
	SetModelStatus(context.Context, names.ModelTag, status.Status, string, map[string]interface{}) error
	WatchModelEnvironVersion(ctx context.Context, tag names.ModelTag) (watcher.NotifyWatcher, error)
}

Facade exposes capabilities required by the worker.

func NewFacade

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

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	EnvironName   string
	GateName      string
	ControllerTag names.ControllerTag
	ModelTag      names.ModelTag
	Logger        logger.Logger

	NewFacade                    func(base.APICaller) (Facade, error)
	NewWorker                    func(context.Context, Config) (worker.Worker, error)
	NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}

ManifoldConfig describes how to configure and construct a Worker, and what registered resources it may depend upon.

Jump to

Keyboard shortcuts

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