ResourceCache stores CachedResource objects
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() }
ResourceCacheMap stores ResourceStatus objects in a map indexed by resource ID. ResourceCacheMap is thread-safe.
type ResourceCacheMap struct {
// contains filtered or unexported fields
}
func NewResourceCacheMap() *ResourceCacheMap
NewResourceCacheMap returns a new empty ResourceCacheMap
func (rc *ResourceCacheMap) Clear()
Clear the cache.
func (rc *ResourceCacheMap) Get(id object.ObjMetadata) ResourceStatus
Get retrieves the resource associated with the ID from the cache. Returns (nil, true) if not found in the cache.
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 (rc *ResourceCacheMap) Put(id object.ObjMetadata, value ResourceStatus)
Put the resource into the cache using the supplied ID, replacing any existing resource with the same ID.
func (rc *ResourceCacheMap) Remove(id object.ObjMetadata)
Remove the resource associated with the ID from the cache.
ResourceCacheReader retrieves CachedResource objects
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 }
ResourceStatus wraps an unstructured resource object, combined with the computed status (whether the status matches the spec).
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 }