Documentation
¶
Overview ¶
Package strategy provides basic interfaces for routing to available plugins and caching metric data.
Index ¶
- Variables
- func NewCache(expiration time.Duration) *cache
- func NewConfigBased(cacheTTL time.Duration) *configBased
- func NewLRU(cacheTTL time.Duration) *lru
- func NewSticky(cacheTTL time.Duration) *sticky
- type AvailablePlugin
- type MapAvailablePlugin
- type Pool
- type RoutingAndCaching
- type SubscriptionType
Constants ¶
This section is empty.
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 NewConfigBased ¶
Types ¶
type AvailablePlugin ¶
type MapAvailablePlugin ¶
type MapAvailablePlugin map[uint32]AvailablePlugin
func (MapAvailablePlugin) Values ¶
func (sm MapAvailablePlugin) Values() []AvailablePlugin
Values returns slice of map values
type Pool ¶
type Pool interface {
RoutingAndCaching
Count() int
Eligible() bool
Insert(a AvailablePlugin) error
Kill(id uint32, reason string)
MoveSubscriptions(to Pool) []subscription
Plugins() MapAvailablePlugin
RLock()
RUnlock()
SelectAndKill(taskID, reason string)
SelectAP(taskID string, configID map[string]ctypes.ConfigValue) (AvailablePlugin, serror.SnapError)
Strategy() RoutingAndCaching
Subscribe(taskID string, subType SubscriptionType)
SubscriptionCount() int
Unsubscribe(taskID string)
Version() int
RestartCount() int
IncRestartCount()
}
type RoutingAndCaching ¶
type RoutingAndCaching interface {
Select(availablePlugins []AvailablePlugin, id string) (AvailablePlugin, error)
Remove(availablePlugins []AvailablePlugin, id string) (AvailablePlugin, error)
CheckCache(metrics []core.Metric, id string) ([]core.Metric, []core.Metric)
UpdateCache(metrics []core.Metric, id string)
CacheHits(ns string, ver int, id string) (uint64, error)
CacheMisses(ns string, ver int, id string) (uint64, error)
AllCacheHits() uint64
AllCacheMisses() uint64
CacheTTL(taskID string) (time.Duration, error)
String() string
}
type SubscriptionType ¶
type SubscriptionType int
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 )
Click to show internal directories.
Click to hide internal directories.