cache

package
v0.3.23-alpha.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareResourverVersion

func CompareResourverVersion(obj interface{}, resourceVersion string) (int, error)

CompareResourverVersion compares the resource version of an object with the provided resource version.

func NewResourceInformer

func NewResourceInformer(lw cache.ListerWatcher,
	selector ResourceSelector,
	transform cache.TransformFunc,
	resyncPeriod time.Duration,
	handler ResourceHandler,
	knownObjects cache.KeyListerGetter,
) cache.Controller

NewResourceInformer creates a new informer that watches for resource events and handles them using the provided ResourceHandler.

Types

type ResourceCache

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

ResourceCache is the main struct that holds the cache storage and key function.

func NewResourceCache

func NewResourceCache() *ResourceCache

NewResourceCache creates and returns a new instance of ResourceCache.

func (*ResourceCache) Add

func (c *ResourceCache) Add(obj interface{}) error

Add adds a new object to the cache.

func (*ResourceCache) Delete

func (c *ResourceCache) Delete(obj interface{}) error

Delete removes an object from the cache.

func (*ResourceCache) Get

func (c *ResourceCache) Get(obj interface{}) (item interface{}, exists bool, err error)

Get retrieves an object from the cache by its reference.

func (*ResourceCache) GetByKey

func (c *ResourceCache) GetByKey(key string) (item interface{}, exists bool, err error)

GetByKey retrieves an object from the cache by its key.

func (*ResourceCache) IsNewer

func (c *ResourceCache) IsNewer(obj interface{}) (bool, error)

IsNewer checks if the provided object is newer than the cached version.

func (*ResourceCache) List

func (c *ResourceCache) List() []interface{}

List returns a list of all objects in the cache.

func (*ResourceCache) ListKeys

func (c *ResourceCache) ListKeys() []string

ListKeys returns a list of all keys in the cache.

func (*ResourceCache) Replace

func (c *ResourceCache) Replace(objs []interface{}, resourceVersion string) error

Replace replaces multiple objects in the cache with the provided resource version.

func (*ResourceCache) Resync

func (c *ResourceCache) Resync() error

Resync refreshes the cache with the latest data from Kubernetes.

func (*ResourceCache) Update

func (c *ResourceCache) Update(obj interface{}) error

Update updates an existing object in the cache.

type ResourceHandler

type ResourceHandler interface {
	OnAdd(obj interface{}) error
	OnUpdate(newObj interface{}) error
	OnDelete(obj interface{}) error
}

ResourceHandler defines the interface for handling resource events.

type ResourceHandlerFuncs

type ResourceHandlerFuncs struct {
	AddFunc    func(obj interface{}) error
	UpdateFunc func(newObj interface{}) error
	DeleteFunc func(obj interface{}) error
}

ResourceHandlerFuncs is a struct that implements the ResourceHandler interface by wrapping functions.

func (ResourceHandlerFuncs) OnAdd

func (r ResourceHandlerFuncs) OnAdd(obj interface{}) error

OnAdd calls the AddFunc field of ResourceHandlerFuncs, handling the add event.

func (ResourceHandlerFuncs) OnDelete

func (r ResourceHandlerFuncs) OnDelete(obj interface{}) error

OnDelete calls the DeleteFunc field of ResourceHandlerFuncs, handling the delete event.

func (ResourceHandlerFuncs) OnUpdate

func (r ResourceHandlerFuncs) OnUpdate(newObj interface{}) error

OnUpdate calls the UpdateFunc field of ResourceHandlerFuncs, handling the update event.

type ResourceSelector

type ResourceSelector interface {
	ApplyToList(*metav1.ListOptions)
	Predicate(interface{}) bool
}

ResourceSelector defines the interface for selecting resources based on certain criteria.

type ResourcecHash

type ResourcecHash struct {
	ResourceVersion string
	Hash            string
}

ResourcecHash represents the resource version and hash of a Kubernetes resource.

Jump to

Keyboard shortcuts

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