cache

package
v0.36.0-flux.9 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceCache

type ResourceCache interface {
	ResourceCacheReader
	// Load one or more resources into the cache, generating the ObjMetadata
	// from the objects.
	Load(...ResourceStatus)
	// Put the resource into the cache using the specified ID.
	Put(object.ObjMetadata, ResourceStatus)
	// Remove the resource associated with the ID from the cache.
	Remove(object.ObjMetadata)
	// Clear the cache.
	Clear()
}

ResourceCache stores CachedResource objects

type ResourceCacheMap

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

ResourceCacheMap stores ResourceStatus objects in a map indexed by resource ID. ResourceCacheMap is thread-safe.

func NewResourceCacheMap

func NewResourceCacheMap() *ResourceCacheMap

NewResourceCacheMap returns a new empty ResourceCacheMap

func (*ResourceCacheMap) Clear

func (rc *ResourceCacheMap) Clear()

Clear the cache.

func (*ResourceCacheMap) Get

Get retrieves the resource associated with the ID from the cache. Returns (nil, true) if not found in the cache.

func (*ResourceCacheMap) Load

func (rc *ResourceCacheMap) Load(values ...ResourceStatus)

Load resources into the cache, generating the ID from the resource itself. Existing resources with the same ID will be replaced.

func (*ResourceCacheMap) Put

Put the resource into the cache using the supplied ID, replacing any existing resource with the same ID.

func (*ResourceCacheMap) Remove

func (rc *ResourceCacheMap) Remove(id object.ObjMetadata)

Remove the resource associated with the ID from the cache.

type ResourceCacheReader

type ResourceCacheReader interface {
	// Get the resource associated with the ID from the cache.
	// If not cached, status will be Unknown and resource will be nil.
	Get(object.ObjMetadata) ResourceStatus
}

ResourceCacheReader retrieves CachedResource objects

type ResourceStatus

type ResourceStatus struct {
	// Resource is the last known value retrieved from the cluster
	Resource *unstructured.Unstructured
	// Status of the resource
	Status status.Status
	// StatusMessage is the human readable reason for the status
	StatusMessage string
}

ResourceStatus wraps an unstructured resource object, combined with the computed status (whether the status matches the spec).

Jump to

Keyboard shortcuts

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