informer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package informer is based on internal package https://github.com/kubernetes-sigs/controller-runtime/tree/v0.8.3/pkg/cache/internal, modified to not be kubernetes API specific. The InformersMap includes a CreateListWatcherFunc that can be used to pass ListWatcherFunc for any API, outside of kubernetes. The cache.ListWatch from the list watcher func is used by the informer to list and watch, and update the cache with objects from an API server. It should be possible to use this cache to watch k8s API as well, but for that, the controller-runtime cache package is more suitable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldIndexName

func FieldIndexName(field string) string

FieldIndexName constructs the name of the index over the given field, for use with an indexer.

func KeyToNamespacedKey

func KeyToNamespacedKey(ns string, baseKey string) string

KeyToNamespacedKey prefixes the given index key with a namespace for use in field selector indexes.

Types

type CacheReader

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

CacheReader wraps a cache.Index to implement the client.CacheReader interface for a single type.

func (*CacheReader) Get

Get checks the indexer for the object and writes a copy of it if found.

func (*CacheReader) List

List lists items out of the indexer and writes them to out.

type CreateListWatcherFunc

type CreateListWatcherFunc func(gvk schema.GroupVersionKind, namespace string, scheme *runtime.Scheme) (*cache.ListWatch, error)

type InformersMap

type InformersMap struct {

	// Scheme maps runtime.Objects to GroupVersionKinds.
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

InformersMap create and caches Informers for (runtime.Object, schema.GroupVersionKind) pairs.

func NewInformersMap

func NewInformersMap(scheme *runtime.Scheme, resync time.Duration, namespace string, createLW CreateListWatcherFunc) *InformersMap

NewInformersMap creates a new InformersMap that can create informers for objects.

func (*InformersMap) Get

Get will create a new Informer and add it to the map of informers if none exists. Returns the Informer from the map.

func (*InformersMap) HasSyncedFuncs

func (m *InformersMap) HasSyncedFuncs() []cache.InformerSynced

HasSyncedFuncs returns all the HasSynced functions for the informers in this map.

func (*InformersMap) Start

func (m *InformersMap) Start(ctx context.Context) error

Start calls Run on each of the informers and sets started to true. Blocks on the context.

func (*InformersMap) WaitForCacheSync

func (m *InformersMap) WaitForCacheSync(ctx context.Context) bool

WaitForCacheSync waits until all the caches have been started and synced.

type MapEntry

type MapEntry struct {
	// Informer is the cached informer
	Informer cache.SharedIndexInformer

	// CacheReader wraps Informer and implements the CacheReader interface for a single type
	Reader CacheReader
}

MapEntry contains the cached data for an Informer.

Jump to

Keyboard shortcuts

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