control

package
v0.13.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2016 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package control PluginManger manages loading, unloading, and swapping of plugins

Index

Constants

View Source
const (
	// DefaultClientTimeout - default timeout for a client connection attempt
	DefaultClientTimeout = time.Second * 3
	// DefaultHealthCheckTimeout - default timeout for a health check
	DefaultHealthCheckTimeout = time.Second * 1
	// DefaultHealthCheckFailureLimit - how any consecutive health check timeouts must occur to trigger a failure
	DefaultHealthCheckFailureLimit = 3
)
View Source
const (
	// PluginTrustDisabled - enum representing plugin trust disabled
	PluginTrustDisabled int = iota
	// PluginTrustEnabled - enum representing plugin trust enabled
	PluginTrustEnabled
	// PluginTrustWarn - enum representing plugin trust warning
	PluginTrustWarn
)
View Source
const (
	// MonitorStopped - enum representation of monitor stopped state
	MonitorStopped monitorState = iota - 1 // default is stopped
	// MonitorStarted - enum representation of monitor started state
	MonitorStarted

	// DefaultMonitorDuration - the default monitor duration.
	DefaultMonitorDuration = time.Second * 1
)
View Source
const (
	// DetectedState is the detected state of a plugin
	DetectedState pluginState = "detected"
	// LoadingState is the loading state of a plugin
	LoadingState pluginState = "loading"
	// LoadedState is the loaded state of a plugin
	LoadedState pluginState = "loaded"
	// UnloadedState is the unloaded state of a plugin
	UnloadedState pluginState = "unloaded"
)
View Source
const (
	// HandlerRegistrationName is the registered name of the control runner
	HandlerRegistrationName = "control.runner"

	// PluginRunning is the running state of a plugin
	PluginRunning availablePluginState = iota - 1 // Default value (0) is Running
	// PluginStopped is the stopped state of a plugin
	PluginStopped
	// PluginDisabled is the disabled state of a plugin
	PluginDisabled

	// MaximumRestartOnDeadPluginEvent is the maximum count of restarting a plugin
	// after the event of control_event.DeadAvailablePluginEvent
	MaxPluginRestartCount = 3
)

Variables

View Source
var (
	ErrPoolNotFound = errors.New("plugin pool not found")
	ErrBadKey       = errors.New("bad key")
)
View Source
var (

	// ErrLoadedPluginNotFound - error message when a loaded plugin is not found
	ErrLoadedPluginNotFound = errors.New("Loaded plugin not found")
	// ErrControllerNotStarted - error message when the Controller was not started
	ErrControllerNotStarted = errors.New("Must start Controller before calling Load()")
)
View Source
var (
	// ErrPluginNotFound - error message when a plugin is not found
	ErrPluginNotFound = errors.New("plugin not found")
	// ErrPluginAlreadyLoaded - error message when a plugin is already loaded
	ErrPluginAlreadyLoaded = errors.New("plugin is already loaded")
	// ErrPluginNotInLoadedState - error message when a plugin must ne in a loaded state
	ErrPluginNotInLoadedState = errors.New("Plugin must be in a LoadedState")
)
View Source
var ErrNotFound = errors.New("metric not found")

ErrNotFound is returned when Get cannot find the given namespace

Functions

func MonitorDurationOption

func MonitorDurationOption(v time.Duration) monitorOption

MonitorDurationOption sets monitor's duration to v.

func New

func New(cfg *Config) *pluginControl

New returns a new pluginControl instance

func OptSetPluginConfig

func OptSetPluginConfig(cf *pluginConfig) pluginManagerOpt

OptSetPluginConfig sets the config on the plugin manager

Types

type Config

type Config struct {
	MaxRunningPlugins int               `json:"max_running_plugins,omitempty"yaml:"max_running_plugins,omitempty"`
	PluginTrust       int               `json:"plugin_trust_level,omitempty"yaml:"plugin_trust_level,omitempty"`
	AutoDiscoverPath  string            `json:"auto_discover_path,omitempty"yaml:"auto_discover_path,omitempty"`
	KeyringPaths      string            `json:"keyring_paths,omitempty"yaml:"keyring_paths,omitempty"`
	CacheExpiration   jsonutil.Duration `json:"cache_expiration,omitempty"yaml:"cache_expiration,omitempty"`
	Plugins           *pluginConfig     `json:"plugins,omitempty"yaml:"plugins,omitempty"`
}

holds the configuration passed in through the SNAP config file

func GetDefaultConfig

func GetDefaultConfig() *Config

get the default snapd configuration

func (*Config) DeletePluginConfigDataNodeField

func (p *Config) DeletePluginConfigDataNodeField(pluginType core.PluginType, name string, ver int, fields ...string) cdata.ConfigDataNode

func (*Config) DeletePluginConfigDataNodeFieldAll

func (p *Config) DeletePluginConfigDataNodeFieldAll(fields ...string) cdata.ConfigDataNode

func (*Config) GetPluginConfigDataNode

func (p *Config) GetPluginConfigDataNode(pluginType core.PluginType, name string, ver int) cdata.ConfigDataNode

func (*Config) GetPluginConfigDataNodeAll

func (p *Config) GetPluginConfigDataNodeAll() cdata.ConfigDataNode

func (*Config) MergePluginConfigDataNode

func (p *Config) MergePluginConfigDataNode(pluginType core.PluginType, name string, ver int, cdn *cdata.ConfigDataNode) cdata.ConfigDataNode

func (*Config) MergePluginConfigDataNodeAll

func (p *Config) MergePluginConfigDataNodeAll(cdn *cdata.ConfigDataNode) cdata.ConfigDataNode

type MTTrie

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

MTTrie struct representing the root in the trie

func NewMTTrie

func NewMTTrie() *MTTrie

NewMTTrie returns an empty trie

func (MTTrie) Add

func (mtt MTTrie) Add(mt *metricType)

Add adds a node with the given namespace with the given MetricType

func (*MTTrie) DeleteByPlugin

func (m *MTTrie) DeleteByPlugin(lp *loadedPlugin)

DeleteByPlugin removes all metrics from the catalog if they match a loadedPlugin

func (MTTrie) Fetch

func (mtt MTTrie) Fetch(ns []string) ([]*metricType, error)

Fetch collects all children below a given namespace and concatenates their metric types into a single slice

func (MTTrie) Get

func (mtt MTTrie) Get(ns []string) ([]*metricType, error)

Get works like fetch, but only returns the MT at the given node and does not gather the node's children.

func (MTTrie) Remove

func (mtt MTTrie) Remove(ns []string) error

Remove removes all children below a given namespace

func (*MTTrie) RemoveMetric

func (m *MTTrie) RemoveMetric(mt metricType)

RemoveMetric removes a specific metric by namespace and version from the tree

func (*MTTrie) String

func (m *MTTrie) String() string

String prints out of the tr(i)e

type PluginControlOpt

type PluginControlOpt func(*pluginControl)

PluginControlOpt is used to set optional parameters on the pluginControl struct

func CacheExpiration

func CacheExpiration(t time.Duration) PluginControlOpt

CacheExpiration is the PluginControlOpt which sets the global metric cache TTL

func MaxRunningPlugins

func MaxRunningPlugins(m int) PluginControlOpt

MaxRunningPlugins sets the maximum number of plugins to run per pool

func OptSetConfig

func OptSetConfig(cfg *Config) PluginControlOpt

OptSetConfig sets the plugin control configuration.

Directories

Path Synopsis
Package strategy provides basic interfaces for routing to available plugins and caching metric data.
Package strategy provides basic interfaces for routing to available plugins and caching metric data.

Jump to

Keyboard shortcuts

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