metadata

package
Version: v0.0.0-...-aed1ee4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package metadata describes metadata paths stored in the cache per target.

Index

Constants

View Source
const (
	// Root node where metadata is cached.
	Root = "meta"

	// Sync is a boolean that reports whether all target state is cached.
	Sync = "sync"
	// Connected is a boolean that reports whether updates are being received.
	Connected = "connected"
	// AddCount is the total number of leaves that have been added.
	AddCount = "targetLeavesAdded"
	// DelCount is the total number of leaves that have been deleted.
	DelCount = "targetLeavesDeleted"
	// LeafCount is the current total leaves stored in the cache.
	LeafCount = "targetLeaves"
	// UpdateCount is the total number of leaf updates received.
	UpdateCount = "targetLeavesUpdated"
	// StaleCount is the total number of leaf updates that had timestamp older
	// than that cached.
	StaleCount = "targetLeavesStale"
	// SuppressedCount is the total number of leaf updates that were suppressed
	// because the update had the same value as already cached.
	SuppressedCount = "targetLeavesSuppressed"
	// LatencyAvg is the average latency between target timestamp and cache
	// reception.
	LatencyAvg = "latencyAvg"
	// LatencyMax is the maximum latency between target timestamp and cache
	// reception.
	LatencyMax = "latencyMax"
	// LatencyMin is the minimum latency between target timestamp and cache
	// reception.
	LatencyMin = "latencyMin"
	// Size is the total number of bytes used to store all values.  This count
	// excludes all indexing overhead.
	Size = "targetSize"
	// LatestTimestamp is the latest timestamp for any update received for the
	// target.
	LatestTimestamp = "latestTimestamp"
)

Variables

View Source
var (
	// TargetBoolValues is the list of all bool metadata fields.
	TargetBoolValues = map[string]bool{
		Sync:      true,
		Connected: true,
	}

	// TargetIntValues is the list of all int64 metadata fields.
	TargetIntValues = map[string]bool{
		AddCount:        true,
		DelCount:        true,
		LeafCount:       true,
		UpdateCount:     true,
		StaleCount:      true,
		SuppressedCount: true,
		LatencyAvg:      true,
		LatencyMax:      true,
		LatencyMin:      true,
		Size:            true,
		LatestTimestamp: true,
	}
)
View Source
var ErrInvalidValue = errors.New("invalid metadata value")

ErrInvalidValue is returned when a metadata operation is attempted on a value that does not exist.

View Source
var ErrUnsetValue = errors.New("unset value")

ErrUnsetValue is returned when a metadata Get is attempted on a value that has not been Set (or Added).

Functions

func Path

func Path(value string) []string

Path is a convenience function that will return the full metadata path for any valid metadata value. Only metadata values registered above in TargetBoolValues and TargetIntValues will return a path. An invalid metadata value will return nil.

Types

type Metadata

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

Metadata is the container for all target specific metadata.

func New

func New() *Metadata

New returns an initialized Metadata structure. Integer values are initialized to 0 and boolean values are initialized to false.

func (*Metadata) AddInt

func (m *Metadata) AddInt(value string, i int64) error

AddInt atomically increments the metadata value specified by i.

func (*Metadata) Clear

func (m *Metadata) Clear()

Clear sets all metadata values to zero values.

func (*Metadata) GetBool

func (m *Metadata) GetBool(value string) (bool, error)

GetBool atomically retrieves the metadata value specified.

func (*Metadata) GetInt

func (m *Metadata) GetInt(value string) (int64, error)

GetInt atomically retrieves the metadata value specified.

func (*Metadata) SetBool

func (m *Metadata) SetBool(value string, v bool) error

SetBool atomically sets the metadata value specified to v.

func (*Metadata) SetInt

func (m *Metadata) SetInt(value string, v int64) error

SetInt atomically sets the metadata value specified to v.

Source Files

Jump to

Keyboard shortcuts

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