charmrevision

package
v0.0.0-...-f7dd865 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 9 Imported by: 8

Documentation

Overview

Package charmrevision defines the charm revision updater worker. This worker is responsible for polling Charmhub every 24 hours to check if there are new revisions available of any repository charm deployed in the model. If so, it will put a document in the Juju database, so that the next time the user runs `juju status`, they can see that there is an update available. This worker also sends anonymised usage metrics to Charmhub when it polls.

This worker doesn't contain much business logic - most of the work is delegated to the facade call.

Index

Constants

This section is empty.

Variables

View Source
var NewAPIFacade = newAPIFacade

NewAPIFacade returns a Facade backed by the supplied APICaller.

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.

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