util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expire

type Expire struct {
	// 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.

func NewExpire

func NewExpire(duration time.Duration) *Expire

NewExpire creates a new Expire object.

func (*Expire) ComputeExpires

func (e *Expire) ComputeExpires() []workloadmeta.EntityID

ComputeExpires returns a list of IDs that have not been seen in the Expire's duration.

func (*Expire) Update

func (e *Expire) Update(id workloadmeta.EntityID, ts time.Time) bool

Update marks the time an ID was last seen. Returns true if the ID is new, false if it was already present in the store.

Jump to

Keyboard shortcuts

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