Documentation ¶
Overview ¶
Package informer provides a wrapper around a client-go SharedIndexInformer for event handling. It removes a lot of boilerplate code that is required when using workqueues
Index ¶
- Constants
- func DiscardAllUpdates(old, new interface{}) bool
- func ReceiveAllUpdates(old, new interface{}) bool
- func WaitForCacheSyncWithTimeout(stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool
- type EndpointSliceEventHandler
- type EventHandler
- type EventHandlerCreateFunction
- type ServiceAndEndpointsEventHandler
- type ServiceEventHandler
- type UpdateFilterFunction
Constants ¶
const ( // DefaultResyncInterval is the default interval that all caches should // periodically resync. AddEventHandlerWithResyncPeriod can specify a // per handler resync period if necessary DefaultResyncInterval = 0 // DefaultNodeInformerThreadiness is the number of worker routines spawned // to services the Node event queue DefaultNodeInformerThreadiness = 10 // DefaultInformerThreadiness is the number of goroutines spawned // to service an informer event queue DefaultInformerThreadiness = 1 // MaxRetries is the maximum number of times we'll retry an item on the queue MaxRetries = 3 )
These constants can be removed at some point They are here to provide backwards-compatibility with the pkg/factory code which provided defaults. The package consumer should make these decisions instead.
Variables ¶
This section is empty.
Functions ¶
func DiscardAllUpdates ¶
func DiscardAllUpdates(old, new interface{}) bool
DiscardAllUpdates always returns false, discarding updates
func ReceiveAllUpdates ¶
func ReceiveAllUpdates(old, new interface{}) bool
ReceiveAllUpdates always returns true meaning that all updates will be enqueued
func WaitForCacheSyncWithTimeout ¶
func WaitForCacheSyncWithTimeout(stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool
Types ¶
type EndpointSliceEventHandler ¶
type EndpointSliceEventHandler interface { AddEndpointSlice(*discovery.EndpointSlice) error DeleteEndpointSlice(*discovery.EndpointSlice) error UpdateEndpointSlice(old, new *discovery.EndpointSlice) error }
type EventHandler ¶
type EventHandler interface { Run(threadiness int, stopChan <-chan struct{}) error GetIndexer() cache.Indexer Synced() bool }
EventHandler is an event handler that responds to Add/Update/Delete events from the informer cache Add and Updates use the provided add function Deletes use the provided delete function
func NewDefaultEventHandler ¶
func NewDefaultEventHandler( name string, informer cache.SharedIndexInformer, addFunc, deleteFunc func(obj interface{}) error, updateFilterFunc UpdateFilterFunction, ) (EventHandler, error)
NewDefaultEventHandler returns a new default event handler The default event handler - Enqueue Adds to the workqueue - Enqueue Updates to the workqueue if they match the predicate function - Enqueue Deletes to the workqueue, and places the deleted object on the deletedIndexer
As the workqueue doesn't carry type information, adds/updates/deletes for a key are all colllapsed. We can only differentiate between add/delete by whether an item exists in the cache or not. Using this implementation, it's not possible to differentiate between adds and updates
func NewTestEventHandler ¶
func NewTestEventHandler( name string, informer cache.SharedIndexInformer, addFunc, deleteFunc func(obj interface{}) error, updateFilterFunc UpdateFilterFunction, ) (EventHandler, error)
NewTestEventHandler returns an event handler similar to NewEventHandler. The only difference is that it ignores the ResourceVersion check.
type EventHandlerCreateFunction ¶
type EventHandlerCreateFunction func( name string, informer cache.SharedIndexInformer, addFunc, deleteFunc func(obj interface{}) error, updateFilterFunc UpdateFilterFunction, ) (EventHandler, error)
EventHandlerCreateFunction is function that creates new event handlers
type ServiceAndEndpointsEventHandler ¶
type ServiceAndEndpointsEventHandler interface { ServiceEventHandler EndpointSliceEventHandler }
type ServiceEventHandler ¶
type UpdateFilterFunction ¶
type UpdateFilterFunction func(old, new interface{}) bool
UpdateFilterFunction returns true if the update is interesting