cache

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cache is responsible for keeping an in memory representation of the controller's models.

The Controller is kept up to date with the database though a changes channel.

Instances in the cache package also provide watchers. These watchers are checking for changes in the in-memory representation and can be used to avoid excess database reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

Application represents an application in a model.

type ApplicationChange

type ApplicationChange struct {
	ModelUUID       string
	Name            string
	Exposed         bool
	CharmURL        string
	Life            life.Value
	MinUnits        int
	Constraints     constraints.Value
	Config          map[string]interface{}
	Subordinate     bool
	Status          status.StatusInfo
	WorkloadVersion string
}

ApplicationChange represents either a new application, or a change to an existing application in a model.

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector is a prometheus.Collector that collects metrics about the Juju global state.

func NewMetricsCollector

func NewMetricsCollector(controller *Controller) *Collector

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 Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the primary cached object.

func NewController

func NewController(config ControllerConfig) (*Controller, error)

NewController creates a new cached controller intance. The changes channel is what is used to supply the cache with the changes in order for the cache to be kept up to date.

func (*Controller) Kill

func (c *Controller) Kill()

Kill is part of the worker.Worker interface.

func (*Controller) Model

func (c *Controller) Model(uuid string) (*Model, error)

Model returns the model for the specified UUID. If the model isn't found, a NotFoundError is returned.

func (*Controller) ModelUUIDs

func (c *Controller) ModelUUIDs() []string

ModelUUIDs returns the UUIDs of the models in the cache.

func (*Controller) Report

func (c *Controller) Report() map[string]interface{}

Report returns information that is used in the dependency engine report.

func (*Controller) Wait

func (c *Controller) Wait() error

Wait is part of the worker.Worker interface.

type ControllerConfig

type ControllerConfig struct {
	// Changes from the event source come over this channel.
	// The changes channel must be non-nil.
	Changes <-chan interface{}

	// Notify is a callback function used primarily for testing, and is
	// called by the controller main processing loop after processing a change.
	// The change processed is passed in as the arg to notify.
	Notify func(interface{})
}

ControllerConfig is a simple config value struct for the controller.

func (*ControllerConfig) Validate

func (c *ControllerConfig) Validate() error

Validate ensures the controller has the right values to be created.

type ControllerGauges

type ControllerGauges struct {
	ModelConfigReads   prometheus.Gauge
	ModelHashCacheHit  prometheus.Gauge
	ModelHashCacheMiss prometheus.Gauge
}

ControllerGauges holds the prometheus gauges for ever increasing values used by the controller.

func (*ControllerGauges) Collect

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

Collect is part of the prometheus.Collector interface.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a cached model in the controller. The model is kept up to date with changes flowing into the cached controller.

func (*Model) Application

func (m *Model) Application(appName string) (*Application, error)

Application returns the application for the input name. If the application is not found, a NotFoundError is returned.

func (*Model) Config

func (m *Model) Config() map[string]interface{}

Config returns the current model config.

func (*Model) Report

func (m *Model) Report() map[string]interface{}

Report returns information that is used in the dependency engine report.

func (*Model) WatchConfig

func (m *Model) WatchConfig(keys ...string) *modelConfigWatcher

WatchConfig creates a watcher for the model config. If keys are specified, the watcher is only signals a change when those keys change values. If no keys are specified, any change in the config will trigger the watcher.

type ModelChange

type ModelChange struct {
	ModelUUID string
	Name      string
	Life      life.Value
	Owner     string // tag maybe?
	Config    map[string]interface{}
	Status    status.StatusInfo
}

ModelChange represents either a new model, or a change to an existing model.

type NotifyWatcher

type NotifyWatcher interface {
	Watcher
	Changes() <-chan struct{}
}

NotifyWatcher will only say something changed.

type RemoveApplication

type RemoveApplication struct {
	ModelUUID string
	Name      string
}

RemoveApplication represents the situation when an application is removed from a model in the database.

type RemoveModel

type RemoveModel struct {
	ModelUUID string
}

RemoveModel represents the situation when a model is removed from the database.

type Watcher

type Watcher interface {
	worker.Worker
	// Stop is currently needed by the apiserver until the resources
	// work on workers instead of things that can be stopped.
	Stop() error
}

Watcher is the common methods

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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