snapshotcombiner

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnapshotCombiner

type SnapshotCombiner[T any] struct {
	// contains filtered or unexported fields
}

func NewSnapshotCombiner

func NewSnapshotCombiner[T any](ttl int) *SnapshotCombiner[T]

NewSnapshotCombiner creates a new wrappedSnapshots combiner that stores structs of type T using a key. Each key is given a time-to-live (ttl) and only valid for ttl calls of GetSnapshots(). Whenever a key is refreshed using AddSnapshot(), the ttl will be reset to the initial value.

func (*SnapshotCombiner[T]) AddSnapshot

func (sc *SnapshotCombiner[T]) AddSnapshot(key string, snapshot []*T)

AddSnapshot adds the given snapshot to the given key (e.g. a node name) and set its ttl to the defaultTTL of the SnapshotCombiner

func (*SnapshotCombiner[T]) GetSnapshots

func (sc *SnapshotCombiner[T]) GetSnapshots() ([]*T, Stats)

GetSnapshots combines all stored wrappedSnapshots from all keys and decreases each keys defaultTTL by one. If the ttl of an entry is less than zero, it will not be returned anymore.

type Stats

type Stats struct {
	Epochs           int // Number of calls to GetSnapshots()
	CurrentSnapshots int // Number of wrappedSnapshots that have been updated since the previous call to GetSnapshots()
	ExpiredSnapshots int // Number of wrappedSnapshots that have a ttl of 0
	TotalSnapshots   int // Number of wrappedSnapshots known
}

Stats contains the status of the SnapshotCombiner when calling GetSnapshots()

Jump to

Keyboard shortcuts

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