cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	READ requestType = iota
	WRITE
	DELETE
)

const for requestType value

Variables

This section is empty.

Functions

func TestNodeMetricCustomInfo

func TestNodeMetricCustomInfo(nodeNames []string, numbers []int64) metrics.NodeMetricsInfo

TestNodeMetricCustomInfo returns the node metrics information

Types

type AutoUpdatingCache

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

AutoUpdatingCache holds a map of metrics of interest with their associated NodeMetricsInfo object.

func MockSelfUpdatingCache

func MockSelfUpdatingCache() *AutoUpdatingCache

MockSelfUpdatingCache returns auto updating cache

func NewAutoUpdatingCache

func NewAutoUpdatingCache() *AutoUpdatingCache

NewAutoUpdatingCache returns an empty metrics cache.

func (*AutoUpdatingCache) DeleteMetric

func (n *AutoUpdatingCache) DeleteMetric(metricName string) error

DeleteMetric keeps track of the number of policies currently using this metric. It is removed from the cache if there are no policies associated with this metric.

func (*AutoUpdatingCache) DeletePolicy

func (n *AutoUpdatingCache) DeletePolicy(namespace string, policyName string) error

DeletePolicy removes the policy removes the policy object at the given namespace/name string from the cache

func (*AutoUpdatingCache) PeriodicUpdate

func (n *AutoUpdatingCache) PeriodicUpdate(period time.Ticker, client metrics.Client, initialData map[string]interface{})

PeriodicUpdate updates all the metrics in the Cache periodically based on a ticker passed to it.

func (*AutoUpdatingCache) ReadMetric

func (n *AutoUpdatingCache) ReadMetric(metricName string) (metrics.NodeMetricsInfo, error)

ReadMetric returns the NodeMetricsInfo object for the passed named metric. If no metric of that name is found it returns an error.

func (*AutoUpdatingCache) ReadPolicy

func (n *AutoUpdatingCache) ReadPolicy(namespace string, policyName string) (telemetrypolicy.TASPolicy, error)

ReadPolicy returns the policy object under the passed name and namespace from the cache.

func (*AutoUpdatingCache) WriteMetric

func (n *AutoUpdatingCache) WriteMetric(metricName string, data metrics.NodeMetricsInfo) error

WriteMetric first checks if there's any data with the request and then sends the request to the cache. It also increments a counter showing how many strategies are using the metric - protecting it from deletion until there are no more associated strategies.

func (*AutoUpdatingCache) WritePolicy

func (n *AutoUpdatingCache) WritePolicy(namespace string, policyName string, policy telemetrypolicy.TASPolicy) error

WritePolicy sends the passed object to be stored in the cache under the namespace/name

type Interface

type Interface interface {
	// contains filtered or unexported methods
}

Interface contains the baseline behaviour for a cache

type Reader

type Reader interface {
	ReadMetric(string) (metrics.NodeMetricsInfo, error)
	ReadPolicy(string, string) (telemetrypolicy.TASPolicy, error)
}

Reader is the functionality to read metrics and policies from the cache

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

ReaderWriter holds the functionality to both read and write metrics and policies

func MockEmptySelfUpdatingCache

func MockEmptySelfUpdatingCache() ReaderWriter

MockEmptySelfUpdatingCache returns auto updating cache

type SelfUpdating

type SelfUpdating interface {
	PeriodicUpdate(time.Ticker, metrics.Client, map[string]interface{})
}

SelfUpdating describes functionality to periodically update all metrics in the metric cache.

type Writer

type Writer interface {
	WriteMetric(string, metrics.NodeMetricsInfo) error
	WritePolicy(string, string, telemetrypolicy.TASPolicy) error
	DeleteMetric(string) error
	DeletePolicy(string, string) error
}

Writer is the functionality to edit metrics (write and delete) and Policies in the cache

Jump to

Keyboard shortcuts

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