juju: github.com/juju/juju/worker/multiwatcher Index | Files | Directories

package multiwatcher

import "github.com/juju/juju/worker/multiwatcher"

Package multiwatcher provides watchers that watch the entire model.

The package is responsible for creating, feeding, and cleaning up after multiwatchers. The core worker gets an event stream from an AllWatcherBacking, and manages the multiwatcher Store.

The behaviour of the multiwatchers is very much tied to the Store implementation. The store provides a mechanism to get changes over time.


Package Files

doc.go manifold.go metrics.go watcher.go worker.go

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a model cache worker. The manifold outputs a *cache.Controller, primarily for the apiserver to depend on and use.

func NewWorkerShim Uses

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

NewWorkerShim is a method used for hooking up the specific NewWorker to the manifold NewWorker config arg. This allows other tests to use the NewWorker to get something that acts as a multiwatcher.Factory without having to cast the worker.

func WorkerFactory Uses

func WorkerFactory(in worker.Worker, out interface{}) error

WorkerFactory extracts a Factory from a *Worker.

type Clock Uses

type Clock interface {
    Now() time.Time

Clock describes the time methods used in this package by the worker.

type Collector Uses

type Collector struct {
    // contains filtered or unexported fields

Collector is a prometheus.Collector that collects metrics about multiwatcher worker.

func NewMetricsCollector Uses

func NewMetricsCollector(worker *Worker) *Collector

NewMetricsCollector returns a new Collector.

func (*Collector) Collect Uses

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect is part of the prometheus.Collector interface.

func (*Collector) Describe Uses

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe is part of the prometheus.Collector interface.

type Config Uses

type Config struct {
    Clock                Clock
    Logger               Logger
    Backing              state.AllWatcherBacking
    PrometheusRegisterer prometheus.Registerer
    Cleanup              func()

Config is an argument struct used to create a Worker.

func (Config) Validate Uses

func (config Config) Validate() error

Validate validates the worker configuration.

type Logger Uses

type Logger interface {
    IsTraceEnabled() bool
    Tracef(string, ...interface{})
    Errorf(string, ...interface{})
    Criticalf(string, ...interface{})

Logger describes the logging methods used in this package by the worker.

type ManifoldConfig Uses

type ManifoldConfig struct {
    StateName string
    Clock     Clock
    Logger    Logger

    // NOTE: what metrics do we want to expose here?
    // loop restart count for one.
    PrometheusRegisterer prometheus.Registerer

    NewWorker     func(Config) (worker.Worker, error)
    NewAllWatcher func(*state.StatePool) state.AllWatcherBacking

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

func (ManifoldConfig) Validate Uses

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type Watcher Uses

type Watcher struct {
    // contains filtered or unexported fields

Watcher watches any changes to the state.

func (*Watcher) Next Uses

func (w *Watcher) Next() ([]multiwatcher.Delta, error)

Next retrieves all changes that have happened since the last time it was called, blocking until there are some changes available.

The result from the initial call to Next() is different from subsequent calls. The latter will reflect changes that have happened since the last Next() call. In contrast, the initial Next() call will return the deltas that represent the model's complete state at that moment, even when the model is empty. In that empty model case an empty set of deltas is returned.

func (*Watcher) Stop Uses

func (w *Watcher) Stop() error

Stop stops the watcher.

type Worker Uses

type Worker struct {
    // contains filtered or unexported fields

Worker runs the primary goroutine for managing the multiwatchers.

func NewWorker Uses

func NewWorker(config Config) (*Worker, error)

NewWorker creates the worker and starts the loop goroutine.

func (*Worker) Kill Uses

func (w *Worker) Kill()

Kill implements worker.Worker.Kill.

func (*Worker) Report Uses

func (w *Worker) Report() map[string]interface{}

Report is shown up in the engine report of the agent.

func (*Worker) Wait Uses

func (w *Worker) Wait() error

Wait implements worker.Worker.Wait.

func (*Worker) WatchController Uses

func (w *Worker) WatchController() multiwatcher.Watcher

WatchController returns entity delta events for all models in the controller.

func (*Worker) WatchModel Uses

func (w *Worker) WatchModel(modelUUID string) multiwatcher.Watcher

WatchModel returns entity delta events just for the specified model.



Package multiwatcher imports 12 packages (graph) and is imported by 4 packages. Updated 2020-06-14. Refresh now. Tools for package owners.