cache

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

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 Cache

type Cache interface {
	cache.Cache

	// GarbageCollectInformers deletes unused
	GarbageCollectInformers(exclude map[schema.GroupVersionKind]bool)
}

func New

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

New initializes and returns a new Cache.

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 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. It uses a standard parameter codec constructed based on the given generated Scheme.

func NewInformersMap

func NewInformersMap(config *rest.Config,
	scheme *runtime.Scheme,
	mapper meta.RESTMapper,
	resync time.Duration,
	namespace string) *InformersMap

NewInformersMap creates a new InformersMap that can create informers for both structured and unstructured objects.

func (*InformersMap) Delete

func (m *InformersMap) Delete(gvk schema.GroupVersionKind)

Delete will stop an Informer and delete it from the map

func (*InformersMap) Get

Get will create a new Informer and add it to the map of InformersMap if none exists. Returns the Informer from the 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 {
	// StopChan is the channel to stop an informer
	StopChan chan 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

type Options

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 base frequency the informers are resynced.
	// Defaults to defaultResyncTime.
	// A 10 percent jitter will be added to the Resync period between informers
	// So that all informers will not send list requests simultaneously.
	Resync *time.Duration

	// Cleanup is the duration after which unused informers should be cleaned up
	Cleanup *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

Jump to

Keyboard shortcuts

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