strategy

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: 12 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	// this subscription is bound to an explicit version
	BoundSubscriptionType subscriptionType = iota
	// this subscription is akin to "latest" and must be moved if a newer version is loaded.
	UnboundSubscriptionType
)

Variables

View Source
var (
	ErrBadType     = errors.New("bad plugin type")
	ErrBadStrategy = errors.New("bad strategy")
	ErrPoolEmpty   = errors.New("plugin pool is empty")
)
View Source
var (
	ErrCacheDoesNotExist = errors.New("cache does not exist")
)
View Source
var (
	ErrCacheEntryDoesNotExist = errors.New("cache entry does not exist")
)
View Source
var (
	ErrCouldNotSelect = errors.New("could not select a plugin")
)
View Source
var GlobalCacheExpiration time.Duration

GlobalCacheExpiration the default time limit for which a cache entry is valid. A plugin can override the GlobalCacheExpiration (default).

View Source
var (
	// This defines the maximum running instances of a loaded plugin.
	// It is initialized at runtime via the cli.
	MaximumRunningPlugins = 3
)

Functions

func NewCache

func NewCache(expiration time.Duration) *cache

func NewLRU

func NewLRU(cacheTTL time.Duration) *lru

func NewSticky

func NewSticky(cacheTTL time.Duration) *sticky

Types

type AvailablePlugin

type AvailablePlugin interface {
	core.AvailablePlugin
	CacheTTL() time.Duration
	CheckHealth()
	ConcurrencyCount() int
	Exclusive() bool
	Kill(r string) error
	RoutingStrategy() plugin.RoutingStrategyType
	SetID(id uint32)
	String() string
	Type() plugin.PluginType
}

type Pool

type Pool interface {
	RoutingAndCaching
	Count() int
	Eligible() bool
	Insert(a AvailablePlugin) error
	Kill(id uint32, reason string)
	MoveSubscriptions(to Pool) []subscription
	Plugins() map[uint32]AvailablePlugin
	RLock()
	RUnlock()
	SelectAndKill(taskID, reason string)
	SelectAP(taskID string) (SelectablePlugin, serror.SnapError)
	Strategy() RoutingAndCaching
	Subscribe(taskID string, subType subscriptionType)
	SubscriptionCount() int
	Unsubscribe(taskID string)
	Version() int
	RestartCount() int
	IncRestartCount()
}

func NewPool

func NewPool(key string, plugins ...AvailablePlugin) (Pool, error)

type RoutingAndCaching

type RoutingAndCaching interface {
	Select(selectablePlugins []SelectablePlugin, taskID string) (SelectablePlugin, error)
	Remove(selectablePlugins []SelectablePlugin, taskID string) (SelectablePlugin, error)
	CheckCache(metrics []core.Metric, taskID string) ([]core.Metric, []core.Metric)
	UpdateCache(metrics []core.Metric, taskID string)
	CacheHits(ns string, ver int, taskID string) (uint64, error)
	CacheMisses(ns string, ver int, taskID string) (uint64, error)
	AllCacheHits() uint64
	AllCacheMisses() uint64
	CacheTTL(taskID string) (time.Duration, error)
	String() string
}

type SelectablePlugin

type SelectablePlugin interface {
	HitCount() int
	LastHit() time.Time
	String() string
	Kill(r string) error
	ID() uint32
}

Jump to

Keyboard shortcuts

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