Documentation
¶
Index ¶
- func CompareResourverVersion(obj interface{}, resourceVersion string) (int, error)
- func NewInformerWithTransformer(lw clientgocache.ListerWatcher, objType runtime.Object, ...) (clientgocache.Store, clientgocache.Controller)
- func NewResourceInformer(lw clientgocache.ListerWatcher, selector ResourceSelector, ...) clientgocache.Controller
- type ResourceCache
- func (c *ResourceCache) Add(obj interface{}) error
- func (c *ResourceCache) Delete(obj interface{}) error
- func (c *ResourceCache) Get(obj interface{}) (item interface{}, exists bool, err error)
- func (c *ResourceCache) GetByKey(key string) (item interface{}, exists bool, err error)
- func (c *ResourceCache) IsNewer(obj interface{}) (bool, error)
- func (c *ResourceCache) List() []interface{}
- func (c *ResourceCache) ListKeys() []string
- func (c *ResourceCache) Replace(objs []interface{}, resourceVersion string) error
- func (c *ResourceCache) Resync() error
- func (c *ResourceCache) Update(obj interface{}) error
- type ResourceHandler
- type ResourceHandlerFuncs
- type ResourceSelector
- type ResourcecHash
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareResourverVersion ¶
CompareResourverVersion compares the resource version of an object with the provided resource version.
func NewInformerWithTransformer ¶
func NewInformerWithTransformer( lw clientgocache.ListerWatcher, objType runtime.Object, resyncPeriod time.Duration, h clientgocache.ResourceEventHandler, transformer TransformFunc, ) (clientgocache.Store, clientgocache.Controller)
NewInformerWithTransformer returns a Store and a controller for populating the store while also providing event notifications. You should only used the returned Store for Get/List operations; Add/Modify/Deletes will cause the event notifications to be faulty. The given transform function will be called on all objects before they will put into the Store and corresponding Add/Modify/Delete handlers will be invoked for them.
func NewResourceInformer ¶
func NewResourceInformer(lw clientgocache.ListerWatcher, selector ResourceSelector, transform TransformFunc, resyncPeriod time.Duration, handler ResourceHandler, knownObjects clientgocache.KeyListerGetter, ) clientgocache.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 ¶
ResourcecHash represents the resource version and hash of a Kubernetes resource.
type TransformFunc ¶
type TransformFunc func(interface{}) (interface{}, error)
TransformFunc allows for transforming an object before it will be processed and put into the controller cache and before the corresponding handlers will be called on it. TransformFunc (similarly to ResourceEventHandler functions) should be able to correctly handle the tombstone of type cache.DeletedFinalStateUnknown
The most common usage pattern is to clean-up some parts of the object to reduce component memory usage if a given component doesn't care about them. given controller doesn't care for them