cache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 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 MockCache added in v0.3.0

type MockCache struct {
	MockCache interface{}
}

MockCache is used in the tests for the core and other packages.

func (MockCache) DeleteMetric added in v0.3.0

func (n MockCache) DeleteMetric(metricName string) error

DeleteMetric is a method implemented for Mock cache.

func (MockCache) DeletePolicy added in v0.3.0

func (n MockCache) DeletePolicy(namespace string, policyName string) error

DeletePolicy is a method implemented for Mock cache.

func (MockCache) ReadMetric added in v0.3.0

func (n MockCache) ReadMetric(string) (metrics.NodeMetricsInfo, error)

ReadMetric is a method implemented for Mock cache.

func (MockCache) ReadPolicy added in v0.3.0

ReadPolicy is a method implemented for Mock cache.

func (MockCache) WriteMetric added in v0.3.0

func (n MockCache) WriteMetric(metricName string, _ metrics.NodeMetricsInfo) error

WriteMetric is a method implemented for Mock cache.

func (MockCache) WritePolicy added in v0.3.0

func (n MockCache) WritePolicy(namespace string, _ string, _ telemetrypolicy.TASPolicy) error

WritePolicy is a method implemented for Mock 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