Documentation ¶
Overview ¶
Package metadata describes metadata paths stored in the cache per target.
Index ¶
- Constants
- Variables
- func LatencyPath(w time.Duration, typ latency.StatType) []string
- func Path(value string) []string
- func RegisterIntValue(name string, val *IntValue)
- func RegisterLatencyMetadata(windowSizes []time.Duration)
- func RegisterServerNameMetadata()
- func RegisterStrValue(name string, val *StrValue)
- func UnregisterIntValue(name string)
- func UnregisterServerNameMetadata()
- func UnregisterStrValue(name string)
- type IntValue
- type Metadata
- func (m *Metadata) AddInt(value string, i int64) error
- func (m *Metadata) Clear()
- func (m *Metadata) GetBool(value string) (bool, error)
- func (m *Metadata) GetInt(value string) (int64, error)
- func (m *Metadata) GetStr(value string) (string, error)
- func (m *Metadata) ResetEntry(entry string) error
- func (m *Metadata) SetBool(value string, v bool) error
- func (m *Metadata) SetInt(value string, v int64) error
- func (m *Metadata) SetStr(value, v string) error
- type StrValue
Constants ¶
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" // ConnectedAddr is a string denoting the last-hop IP address of a connected // target. ConnectedAddr = "connectedAddress" // 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" // EmptyCount is the total number of notifications delivered that contain no // updates or deletes. EmptyCount = "targetLeavesEmpty" // 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" // FutureCount is the total number of leaf updates that are rejected because // of having timestamp too far in the future. FutureCount = "targetLeavesFuture" // SuppressedCount is the total number of leaf updates that were suppressed // because the update had the same value as already cached. SuppressedCount = "targetLeavesSuppressed" // 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" // ConnectError is the error related to connection failure. ConnectError = "connectError" // ServerName is an optional metadata used to identify the server to clients. ServerName = "serverName" )
Variables ¶
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]*IntValue{ AddCount: {[]string{Root, AddCount}, true}, DelCount: {[]string{Root, DelCount}, true}, EmptyCount: {[]string{Root, EmptyCount}, true}, LeafCount: {[]string{Root, LeafCount}, true}, UpdateCount: {[]string{Root, UpdateCount}, true}, StaleCount: {[]string{Root, StaleCount}, true}, FutureCount: {[]string{Root, FutureCount}, true}, SuppressedCount: {[]string{Root, SuppressedCount}, true}, Size: {[]string{Root, Size}, true}, LatestTimestamp: {[]string{Root, LatestTimestamp}, true}, } // TargetStrValues is the list of all string metadata fields. TargetStrValues = map[string]*StrValue{ ConnectedAddr: {InitEmptyStr: true}, ConnectError: {InitEmptyStr: false}, } )
var ErrInvalidValue = errors.New("invalid metadata value")
ErrInvalidValue is returned when a metadata operation is attempted on a value that does not exist.
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 LatencyPath ¶
LatencyPath returns the metadata path for the latency statistics of window w and type typ.
func Path ¶
Path is a convenience function that will return the full metadata path for any valid metadata value. Only metadata values registered above in TargetBoolValues, TargetIntValues, and TargetStrValues will return a path. An invalid metadata value will return nil.
func RegisterIntValue ¶
RegisterIntValue registers an int64 type metadata whose path and options are in val.
func RegisterLatencyMetadata ¶
RegisterLatencyMetadata registers latency stats metadata for time windows specified in windowSizes. RegisterLatencyMetadata is not thread-safe and should be called before any metadata.Metadata is instantiated.
func RegisterServerNameMetadata ¶ added in v0.10.0
func RegisterServerNameMetadata()
RegisterServerNameMetadata registers the serverName metadata.
func RegisterStrValue ¶ added in v0.10.0
RegisterStrValue registers a string type metadata.
func UnregisterIntValue ¶
func UnregisterIntValue(name string)
UnregisterIntValue unregisters an int64 type metadata name.
func UnregisterServerNameMetadata ¶ added in v0.11.0
func UnregisterServerNameMetadata()
UnregisterServerNameMetadata registers the serverName metadata.
func UnregisterStrValue ¶ added in v0.11.0
func UnregisterStrValue(name string)
UnregisterStrValue unregisters a string type metadata.
Types ¶
type IntValue ¶
type IntValue struct { Path []string // Path of the int64 metadata InitZero bool // Whether to initiate to 0 (for counters starting from 0). }
IntValue contains the path and other options for an int64 metadata.
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. Boolean values are initialized to false. String values are initialized to empty string.
func (*Metadata) Clear ¶
func (m *Metadata) Clear()
Clear sets all metadata values to zero values, except that ConnectError is set to EmptyError.
func (*Metadata) ResetEntry ¶
ResetEntry resets metadata entry to zero value. It will be deleted if it is Int with InitZero as false, or Str with InitEmptyStr as false.