modelcache

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCacheController

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

ExtractCacheController extracts a *cache.Controller from a *cacheWorker.

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 NewWorker

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

NewWorker creates a new cacheWorker, and starts an all model watcher.

Types

type Clock

type Clock interface {
	// After waits for the duration to elapse and then sends the
	// current time on the returned channel.
	After(time.Duration) <-chan time.Time
}

Clock provides an interface for dealing with clocks.

type Config

type Config struct {
	StatePool            *state.StatePool
	Hub                  Hub
	InitializedGate      Unlocker
	Logger               Logger
	PrometheusRegisterer prometheus.Registerer
	Cleanup              func()

	// Notify is used primarily for testing, and is passed through
	// to the cache.Controller. It is called every time the controller
	// processes an event.
	Notify func(interface{})

	// WatcherFactory supplies the watcher that supplies deltas from state.
	// We use a factory because we do not allow the worker loop to be crashed
	// by a watcher that stops in an error state.
	// Watcher acquisition my occur multiple times during a worker life-cycle.
	WatcherFactory func() multiwatcher.Watcher

	// WatcherRestartDelayMin is the minimum duration of the worker pause
	// before instantiating a new all-watcher when the previous one returns an
	// error.
	// This is intended to prevent log flooding in the case of unrecoverable
	// watcher errors.
	WatcherRestartDelayMin time.Duration

	// WatcherRestartDelayMax is the maximum duration of the worker pause
	// before instantiating a new all-watcher when the previous one returns an
	// error.
	WatcherRestartDelayMax time.Duration

	// Clock is used to enforce watcher restart delays.
	Clock Clock
}

Config describes the necessary fields for NewWorker.

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures all the necessary values are specified

func (Config) WithDefaultRestartStrategy

func (c Config) WithDefaultRestartStrategy() Config

WithDefaultRestartStrategy returns a new config with production-use settings for the all-watcher restart strategy.

type Hub

type Hub interface {
	Subscribe(topic string, handler interface{}) (func(), error)
}

Hub defines the methods of the apiserver centralhub that the peer grouper uses.

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
	CentralHubName      string
	MultiwatcherName    string
	InitializedGateName string
	Logger              Logger

	PrometheusRegisterer prometheus.Registerer

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

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 Unlocker

type Unlocker interface {
	Unlock()
}

Unlocker is used to indicate that the model cache is ready to be used.

Jump to

Keyboard shortcuts

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