informer

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

pkg/informer/factory.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientProvider

type ClientProvider interface {
	For(obj runtime.Object) (GenericClient, error)
}

type Factory

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

All mappings key: gvk

func SharedInformerFactory

func SharedInformerFactory(
	cp ClientProvider,
	restConfig *rest.Config,
	queueRegistry *queue.QueueRegistry,
	defaultWq *queue.Workqueue,
	scheme *runtime.Scheme,
	kfg *konfig.Konfig,
) *Factory

func (*Factory) For

For creates or returns a SharedIndexInformer for the given object type. Uses the client provider to build the ListerWatcher via newListWatch. Each type gets exactly one informer — subsequent calls return the cached one. The informer is not started here — Start() starts all registered informers.

func (*Factory) ForListerWatcher

func (f *Factory) ForListerWatcher(lw cache.ListerWatcher, obj runtime.Object, ctx context.Context, opts Options) cache.SharedIndexInformer

ForListerWatcher creates or returns a SharedIndexInformer using an explicit ListerWatcher. Used for unstructured CRDs where the dynamic client provides the ListerWatcher directly, bypassing the typed client provider entirely. The scheme is never consulted — no conversion errors for unstructured types.

func (*Factory) IsMissing

func (f *Factory) IsMissing(key string) bool

IsMissing CRDs on startup

func (*Factory) IsReady

func (f *Factory) IsReady() bool

IsReady returns true if the factory has been started.

func (*Factory) Missing

func (f *Factory) Missing() map[string]*InformerEntry

Missing CRDs on startup

func (*Factory) Name

func (f *Factory) Name() string

func (*Factory) Registered

func (f *Factory) Registered() map[string]*InformerEntry

Registered CRDs

func (*Factory) RemoveMissing

func (f *Factory) RemoveMissing(gvkStr string)

RemoveMissing CRDs in between runs

func (*Factory) SetMissingOnStartup

func (f *Factory) SetMissingOnStartup(missing map[string]*InformerEntry)

SetMissing CRDs on startup

func (*Factory) Shutdown

func (f *Factory) Shutdown(ctx context.Context)

func (*Factory) Start

func (f *Factory) Start(ctx context.Context) error

Start signals readiness and starts all registered informers. Must be called exactly once — enforced by ErrFactoryAlreadyStarted.

func (*Factory) Started

func (f *Factory) Started() bool

func (*Factory) Status

func (f *Factory) Status() string

Status returns a summary of all informers and their sync state. Used by the health server /katalog endpoint.

func (*Factory) WaitForCacheSync

func (f *Factory) WaitForCacheSync(ctx context.Context) bool

WaitForCacheSync blocks until all informer caches have synced or ctx is done. It only waits on informers that were successfully created and started. Informers for missing CRDs (where ListWatch failed) should never be added to the factory, so they are naturally excluded here.

type GenericClient

type GenericClient interface {
	List(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error)
	Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
}

type InformerEntry

type InformerEntry struct {
	Informer cache.SharedIndexInformer
	Name     string
	Resync   time.Duration
	Missing  bool
	GVK      *schema.GroupVersionKind

	// Store the context and cancel function
	Ctx             context.Context    // stored context
	Cancel          context.CancelFunc // stored cancel function
	WasNeverStarted bool
}

InformerEntry holds an informer and its metadata — avoids storing a single shared opts on the factory which caused the name bug.

type Options

type Options struct {
	Name          string
	Resync        time.Duration
	Wq            *queue.Workqueue
	LabelSelector string
	FieldSelector string
}

Jump to

Keyboard shortcuts

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