charmrevision

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

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 runs a charm revision worker according to the supplied configuration.

func NewWorker

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

NewWorker returns a worker that calls UpdateLatestRevisions on the configured RevisionUpdater, once when started and subsequently every Period.

Types

type Config

type Config struct {

	// RevisionUpdater is the worker's view of the controller.
	RevisionUpdater RevisionUpdater

	// Clock is the worker's view of time.
	Clock clock.Clock

	// Period is the time between charm revision updates.
	Period time.Duration

	// Logger is the logger used for debug logging in this worker.
	Logger Logger
}

Config defines the operation of a charm revision updater worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the configuration cannot be expected to start a functional worker.

type Facade

type Facade interface {
	RevisionUpdater
}

Facade has all the controller methods used by the charm revision worker.

func NewAPIFacade

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

NewAPIFacade returns a Facade backed by the supplied APICaller.

type Logger

type Logger interface {
	Debugf(message string, args ...interface{})
}

Logger is a debug-only logger interface.

type ManifoldConfig

type ManifoldConfig struct {

	// The named dependencies will be exposed to the start func as resources.
	APICallerName string
	Clock         clock.Clock

	// The remaining dependencies will be used with the resources to configure
	// and create the worker. The period must be greater than 0; the NewFacade
	// and NewWorker fields must not be nil. charmrevision.NewWorker, and
	// NewAPIFacade, are suitable implementations for most clients.
	Period    time.Duration
	NewFacade func(base.APICaller) (Facade, error)
	NewWorker func(Config) (worker.Worker, error)
	Logger    Logger
}

ManifoldConfig describes how to create a worker that checks for updates available to deployed charms in an environment.

type RevisionUpdater

type RevisionUpdater interface {

	// UpdateLatestRevisions causes the environment to be scanned, the charm
	// store to be interrogated, and model representations of updated charms
	// to be stored in the environment.
	//
	// That is sufficiently complex that the logic should be implemented by
	// the worker, not directly on the apiserver; as this functionality needs
	// to change/mature, please migrate responsibilities down to the worker
	// and grow this interface to match.
	UpdateLatestRevisions() error
}

RevisionUpdater exposes the "single" capability required by the worker. As the worker gains more responsibilities, it will likely need more; see storageprovisioner for a helpful model to grow towards.

Jump to

Keyboard shortcuts

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