Documentation ¶
Overview ¶
Package informer provides a generic mechanism for listening for changes to resources.
Index ¶
- type Event
- type EventType
- type Getter
- type Informer
- func (i *Informer[T, L]) Sync(ctx context.Context, opt Option, events chan<- Event[T]) error
- func (i *Informer[T, L]) Watch(ctx context.Context, opt Option, events chan<- Event[T]) error
- func (i *Informer[T, L]) WatchWithCache(ctx context.Context, opt Option, events chan<- Event[T]) (Getter[T], error)
- func (i *Informer[T, L]) WatchWithLazyCache(ctx context.Context, opt Option, events chan<- Event[T]) (Getter[T], error)
- type Option
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event[T runtime.Object] struct { // Type is Added, Modified, Deleted, or Sync. Type EventType // Object is: // * If Type is Added, Modified or Sync: the new state of the object. // * If Type is Deleted: the state of the object immediately before deletion. Object T }
Event represents a single event to a watched resource.
type Getter ¶
type Getter[T runtime.Object] interface { Get(name string) (T, bool) GetWithNamespace(name, namespace string) (T, bool) List() []T }
Getter is a wrapper around a cache.Store that provides Get and List methods.
type Informer ¶
type Informer[T runtime.Object, L runtime.Object] struct { ListFunc func(ctx context.Context, opts metav1.ListOptions) (L, error) WatchFunc func(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) }
Informer is a wrapper around a Get/List/Watch function.
func NewInformer ¶
NewInformer returns a new Informer.
func (*Informer[T, L]) Watch ¶
Watch starts a goroutine that watches the resource and sends events to the events channel.
type Option ¶
type Option struct { LabelSelector string FieldSelector string AnnotationSelector string // contains filtered or unexported fields }
Option is used to filter events.
type Watcher ¶
type Watcher[T runtime.Object, L runtime.Object] interface { // List returns an object containing a list of the resources matching the provided options. List(ctx context.Context, opts metav1.ListOptions) (L, error) // Watch returns an object that watches the resources matching the provided options. Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) }
Watcher is an interface for objects that know how to watch resources.
Click to show internal directories.
Click to hide internal directories.