metadata

package
v1.0.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadKubevirtMetadata

func LoadKubevirtMetadata(metadataCache *Cache) api.KubeVirtMetadata

LoadKubevirtMetadata loads and returns all KubeVirt metadata. It serves as a convenient helper for processing the `KubeVirtMetadata` data structure as a whole. It is recommended to use individual loaders when possible.

Types

type Cache

type Cache struct {
	UID              SafeData[types.UID]
	Migration        SafeData[api.MigrationMetadata]
	GracePeriod      SafeData[api.GracePeriodMetadata]
	AccessCredential SafeData[api.AccessCredentialMetadata]
	MemoryDump       SafeData[api.MemoryDumpMetadata]
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) Listen

func (c *Cache) Listen() <-chan struct{}

Listen to a notification signal about the cache content changes. Notifications are sent implicitly when the cache data is being changed.

func (*Cache) ResetNotification

func (c *Cache) ResetNotification()

ResetNotification clears the notification signal.

type SafeData

type SafeData[T comparable] struct {
	// contains filtered or unexported fields
}

func (*SafeData[T]) Load

func (d *SafeData[T]) Load() (T, bool)

Load reads and returns safely the data and a flag. The flag specifies if the data is already initialized (true) or not (false). Data which is not yet initialized has never been stored.

func (*SafeData[T]) Set

func (d *SafeData[T]) Set(data T)

Set persists safely the inputted data. As a side effect, it marks the data as initialized.

Note: Unlike Store, this method does not have a notification side effect.

func (*SafeData[T]) Store

func (d *SafeData[T]) Store(data T)

Store persists safely the inputted data. As a side effect, it marks the data as initialized and in case a notification channel exists, a signal is sent.

func (*SafeData[T]) String

func (d *SafeData[T]) String() string

func (*SafeData[T]) WithSafeBlock

func (d *SafeData[T]) WithSafeBlock(f func(data *T, initialized bool))

WithSafeBlock calls the provided function with the data (reference) and a flag that specifies if the data is already initialized (true) or not (false). Data which is not yet initialized has never been stored. As a side effect, the method marks the data as initialized. In case a notification channel exists and the data changed, a signal is sent.

Access to the data is protected by locks during the execution.

Jump to

Keyboard shortcuts

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