watch

package
v3.9.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddFunction

type AddFunction func(manager.Manager) error

type ControllerSwitch

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

func NewSwitch

func NewSwitch() *ControllerSwitch

func (*ControllerSwitch) Enter

func (c *ControllerSwitch) Enter() bool

func (*ControllerSwitch) Exit

func (c *ControllerSwitch) Exit()

func (*ControllerSwitch) Stop

func (c *ControllerSwitch) Stop()

type Manager

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

Manager allows us to dynamically configure what kinds are watched.

func New

func New(c RemovableCache) (*Manager, error)

func (*Manager) GetManagedGVK

func (wm *Manager) GetManagedGVK() []schema.GroupVersionKind

func (*Manager) NewRegistrar

func (wm *Manager) NewRegistrar(parent string, events chan<- event.GenericEvent) (*Registrar, error)

func (*Manager) OnAdd

func (wm *Manager) OnAdd(obj interface{})

OnAdd implements cache.ResourceEventHandler. Called by informers.

func (*Manager) OnDelete

func (wm *Manager) OnDelete(obj interface{})

OnDelete implements cache.ResourceEventHandler. Called by informers.

func (*Manager) OnUpdate

func (wm *Manager) OnUpdate(oldObj, newObj interface{})

OnUpdate implements cache.ResourceEventHandler. Called by informers.

func (*Manager) RemoveRegistrar

func (wm *Manager) RemoveRegistrar(parentName string) error

RemoveRegistrar removes a registrar and all its watches.

func (*Manager) Start

func (wm *Manager) Start(ctx context.Context) error

Start runs the watch manager, processing events received from dynamic informers and distributing them to registrars.

type Registrar

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

A Registrar allows a parent to add/remove child watches.

func (*Registrar) AddWatch

func (r *Registrar) AddWatch(gvk schema.GroupVersionKind) error

AddWatch registers a watch for the given kind.

AddWatch will only block if all of the following are true:

  • The registrar is joining an existing watch
  • The registrar's event channel does not have sufficient capacity to receive existing resources
  • The consumer of the channel does not receive any unbuffered events.

XXXX also may block if the watch manager has not been started.

func (*Registrar) IfWatching

func (r *Registrar) IfWatching(gvk schema.GroupVersionKind, fn func() error) (bool, error)

IfWatching executes the passed function if the provided GVK is being watched by the registrar, ignoring it if not. It returns whether the function was executed and any errors returned by the executed function.

func (*Registrar) RemoveWatch

func (r *Registrar) RemoveWatch(gvk schema.GroupVersionKind) error

RemoveWatch removes a watch for the given kind. Ignores the request if the kind was not previously watched.

func (*Registrar) ReplaceWatch

func (r *Registrar) ReplaceWatch(gvks []schema.GroupVersionKind) error

ReplaceWatch replaces the set of watched resources.

type RemovableCache

type RemovableCache interface {
	GetInformerNonBlocking(obj client.Object) (cache.Informer, error)
	List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
	Remove(obj client.Object) error
}

RemovableCache is a subset variant of the cache.Cache interface. It supports non-blocking calls to get informers, as well as the ability to remove an informer dynamically.

type Set

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

Set tracks a set of watched resource GVKs.

func NewSet

func NewSet() *Set

NewSet constructs a new watchSet.

func (*Set) Add

func (w *Set) Add(gvks ...schema.GroupVersionKind)

func (*Set) AddSet

func (w *Set) AddSet(other *Set)

func (*Set) Contains

func (w *Set) Contains(gvk schema.GroupVersionKind) bool

func (*Set) Difference

func (w *Set) Difference(other *Set) *Set

Difference returns items in the set that are not in the other (provided) set.

func (*Set) DoForEach

func (w *Set) DoForEach(f func(gvk schema.GroupVersionKind) error) error

DoForEach locks Set to prevent mutations and executes f on every element currently in the set. Exits early if f returns an error.

func (*Set) Dump

func (w *Set) Dump() map[schema.GroupVersionKind]bool

func (*Set) Equals

func (w *Set) Equals(other *Set) bool

func (*Set) Intersection

func (w *Set) Intersection(other *Set) *Set

Intersection returns a set composed of all items that are both in set w and other.

func (*Set) Items

func (w *Set) Items() []schema.GroupVersionKind

func (*Set) RLock

func (w *Set) RLock()

RLock acquires a read lock on Set.

func (*Set) RUnlock

func (w *Set) RUnlock()

RUnlock releases a read lock on Set.

func (*Set) Remove

func (w *Set) Remove(gvks ...schema.GroupVersionKind)

func (*Set) RemoveSet

func (w *Set) RemoveSet(other *Set)

func (*Set) Replace

func (w *Set) Replace(other *Set, fns ...func())

Replace locks Set for mutation, replaces Set with other, and then executes any passed callbacks before releasing the lock.

func (*Set) Size

func (w *Set) Size() int

func (*Set) String

func (w *Set) String() string

Jump to

Keyboard shortcuts

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