utils

package
v0.0.2-0...-4ce78c8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetadataAsTags

func AddMetadataAsTags(name, value string, metadataAsTags map[string]string, glob map[string]glob.Glob, tags *TagList)

AddMetadataAsTags converts name and value into tags based on the metadata as tags configuration and patterns

func ComputeTagsHash

func ComputeTagsHash(tags []string) string

ComputeTagsHash returns a hash of the supplied tags.

func ConcatenateTags

func ConcatenateTags(slices [][]string) []string

ConcatenateTags is a fast way to concatenate multiple tag arrays in a single one.

func InitMetadataAsTags

func InitMetadataAsTags(metadataAsTags map[string]string) (map[string]string, map[string]glob.Glob)

InitMetadataAsTags prepares labels and annotations as tags - It lower-case all the labels in metadataAsTags - It compiles all the patterns and stores them in a map of glob.Glob objects

func StringInRuneset

func StringInRuneset(name, subset string) bool

StringInRuneset tests whether all runes of a string are in a given subset returns false if any rune in the string is not found in the subset

Types

type Expire

type Expire struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Expire implements a simple last-seen-time-based expiry logic for watching for disappearing entities (for triggering events or just cache housekeeping). User classes define an expiry delay, then call Update every time they encounter a given entity. ComputeExpires() returns the entity names that have not been seen for longer than the configured delay. As Expire keeps an internal state of entity names, Update will return true if a name is new, false otherwise.

func NewExpire

func NewExpire(expiryDuration time.Duration) (*Expire, error)

NewExpire creates a new Expire object. Called when a Collector is started.

func (*Expire) ComputeExpires

func (e *Expire) ComputeExpires() ([]string, error)

ComputeExpires should be called right after an Update.

func (*Expire) Update

func (e *Expire) Update(container string, ts time.Time) bool

Update the map of the Expire obect.

type TagList

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

TagList allows collector to incremental build a tag list then export it easily to []string format

func NewTagList

func NewTagList() *TagList

NewTagList creates a new object ready to use

func (*TagList) AddAuto

func (l *TagList) AddAuto(name, value string)

AddAuto determine the tag cardinality and will call the proper method AddLow or AddHigh if the name value starts with '+' character

func (*TagList) AddHigh

func (l *TagList) AddHigh(name string, value string)

AddHigh adds a new high cardinality tag to the map, or replace if already exists. It will skip empty values/names, so it's safe to use without verifying the value is not empty.

func (*TagList) AddLow

func (l *TagList) AddLow(name string, value string)

AddLow adds a new low cardinality tag to the list, or replace if already exists. It will skip empty values/names, so it's safe to use without verifying the value is not empty.

func (*TagList) AddOrchestrator

func (l *TagList) AddOrchestrator(name string, value string)

AddOrchestrator adds a new orchestrator-level cardinality tag to the map, or replice if already exists. It will skip empty values/names, so it's safe to use without verifying the value is not empty.

func (*TagList) AddStandard

func (l *TagList) AddStandard(name string, value string)

AddStandard adds a new standard tag to the list, or replace if already exists. It adds the standard tag to the low cardinality tag list as well. It will skip empty values/names, so it's safe to use without verifying the value is not empty.

func (*TagList) Compute

func (l *TagList) Compute() ([]string, []string, []string, []string)

Compute returns four string arrays in the format "tag:value" - low cardinality - orchestrator cardinality - high cardinality - standard tags

func (*TagList) Copy

func (l *TagList) Copy() *TagList

Copy creates a deep copy of the taglist object for reuse

Jump to

Keyboard shortcuts

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