controller-runtime: sigs.k8s.io/controller-runtime/pkg/cache Index | Files | Directories

package cache

import "sigs.k8s.io/controller-runtime/pkg/cache"

Package cache provides object caches that act as caching client.Reader instances and help drive Kubernetes-object-based event handlers.

Index

Package Files

cache.go doc.go informer_cache.go multi_namespace_cache.go

type Cache Uses

type Cache interface {
    // Cache acts as a client to objects stored in the cache.
    client.Reader

    // Cache loads informers and adds field indices.
    Informers
}

Cache knows how to load Kubernetes objects, fetch informers to request to receive events for Kubernetes objects (at a low-level), and add indices to fields on the objects stored in the cache.

func New Uses

func New(config *rest.Config, opts Options) (Cache, error)

New initializes and returns a new Cache.

type Informer Uses

type Informer interface {
    // AddEventHandler adds an event handler to the shared informer using the shared informer's resync
    // period.  Events to a single handler are delivered sequentially, but there is no coordination
    // between different handlers.
    AddEventHandler(handler toolscache.ResourceEventHandler)
    // AddEventHandlerWithResyncPeriod adds an event handler to the shared informer using the
    // specified resync period.  Events to a single handler are delivered sequentially, but there is
    // no coordination between different handlers.
    AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, resyncPeriod time.Duration)
    // AddIndexers adds more indexers to this store.  If you call this after you already have data
    // in the store, the results are undefined.
    AddIndexers(indexers toolscache.Indexers) error
    //HasSynced return true if the informers underlying store has synced
    HasSynced() bool
}

Informer - informer allows you interact with the underlying informer

type Informers Uses

type Informers interface {
    // GetInformer fetches or constructs an informer for the given object that corresponds to a single
    // API kind and resource.
    GetInformer(obj runtime.Object) (Informer, error)

    // GetInformerForKind is similar to GetInformer, except that it takes a group-version-kind, instead
    // of the underlying object.
    GetInformerForKind(gvk schema.GroupVersionKind) (Informer, error)

    // Start runs all the informers known to this cache until the given channel is closed.
    // It blocks.
    Start(stopCh <-chan struct{}) error

    // WaitForCacheSync waits for all the caches to sync.  Returns false if it could not sync a cache.
    WaitForCacheSync(stop <-chan struct{}) bool

    // Informers knows how to add indices to the caches (informers) that it manages.
    client.FieldIndexer
}

Informers knows how to create or fetch informers for different group-version-kinds, and add indices to those informers. It's safe to call GetInformer from multiple threads.

type NewCacheFunc Uses

type NewCacheFunc func(config *rest.Config, opts Options) (Cache, error)

NewCacheFunc - Function for creating a new cache from the options and a rest config

func MultiNamespacedCacheBuilder Uses

func MultiNamespacedCacheBuilder(namespaces []string) NewCacheFunc

MultiNamespacedCacheBuilder - Builder function to create a new multi-namespaced cache. This will scope the cache to a list of namespaces. Listing for all namespaces will list for all the namespaces that this knows about.

type Options Uses

type Options struct {
    // Scheme is the scheme to use for mapping objects to GroupVersionKinds
    Scheme *runtime.Scheme

    // Mapper is the RESTMapper to use for mapping GroupVersionKinds to Resources
    Mapper meta.RESTMapper

    // Resync is the resync period. Defaults to defaultResyncTime.
    Resync *time.Duration

    // Namespace restricts the cache's ListWatch to the desired namespace
    // Default watches all namespaces
    Namespace string
}

Options are the optional arguments for creating a new InformersMap object

Directories

PathSynopsis
informertest
internal

Package cache imports 17 packages (graph) and is imported by 36 packages. Updated 2019-07-09. Refresh now. Tools for package owners.