Documentation
¶
Overview ¶
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.
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 cache worker. The manifold outputs a *cache.Controller, primarily for the apiserver to depend on and use.
func NewWorkerShim ¶
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 ¶
func WorkerFactory(in worker.Worker, out interface{}) error
WorkerFactory extracts a Factory from a *Worker.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is a prometheus.Collector that collects metrics about multiwatcher worker.
func NewMetricsCollector ¶
NewMetricsCollector returns a new Collector.
func (*Collector) Collect ¶
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect is part of the prometheus.Collector interface.
func (*Collector) Describe ¶
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe is part of the prometheus.Collector interface.
type Config ¶
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.
type Logger ¶
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 ¶
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 ¶
func (config ManifoldConfig) Validate() error
Validate validates the manifold configuration.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches any changes to the state.
func (*Watcher) Next ¶
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.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker runs the primary goroutine for managing the multiwatchers.
func (*Worker) WatchController ¶
func (w *Worker) WatchController() multiwatcher.Watcher
WatchController returns entity delta events for all models in the controller.
func (*Worker) WatchModel ¶
func (w *Worker) WatchModel(modelUUID string) multiwatcher.Watcher
WatchModel returns entity delta events just for the specified model.