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 ¶
- func FieldIndexName(field string) string
- func KeyToNamespacedKey(ns string, baseKey string) string
- type CacheReader
- type CreateListWatcherFunc
- type InformersMap
- func (m *InformersMap) Get(ctx context.Context, gvk schema.GroupVersionKind, obj runtime.Object) (bool, *MapEntry, error)
- func (m *InformersMap) HasSyncedFuncs() []cache.InformerSynced
- func (m *InformersMap) Start(ctx context.Context) error
- func (m *InformersMap) WaitForCacheSync(ctx context.Context) bool
- type MapEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldIndexName ¶
FieldIndexName constructs the name of the index over the given field, for use with an indexer.
func KeyToNamespacedKey ¶
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) List ¶
func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...client.ListOption) error
List lists items out of the indexer and writes them to out.
type CreateListWatcherFunc ¶
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 ¶
func (m *InformersMap) Get(ctx context.Context, gvk schema.GroupVersionKind, obj runtime.Object) (bool, *MapEntry, error)
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.