apiserverk8s.io/apiserver/pkg/storage/cacher Index | Files | Directories

package cacher

import "k8s.io/apiserver/pkg/storage/cacher"

Index

Constants

const (
	Pending status = iota
	Ready
	Stopped
)

Functions

func NewListerWatcher

func NewListerWatcher(storage storage.Interface, resourcePrefix string, newListFunc func() runtime.Object, contextMetadata metadata.MD) cache.ListerWatcher

NewListerWatcher returns a storage.Interface backed ListerWatcher.

Types

type Cacher

type Cacher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cacher is responsible for serving WATCH and LIST requests for a given resource from its internal cache and updating its cache in the background based on the underlying storage contents. Cacher implements storage.Interface (although most of the calls are just delegated to the underlying storage).

func NewCacherFromConfig

func NewCacherFromConfig(config Config) (*Cacher, error)

NewCacherFromConfig creates a new Cacher responsible for servicing WATCH and LIST requests from its internal cache and updating its cache in the background based on the given configuration.

func (*Cacher) Count

func (c *Cacher) Count(pathPrefix string) (int64, error)

Count implements storage.Interface.

func (*Cacher) Create

func (c *Cacher) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error

Create implements storage.Interface.

func (*Cacher) Delete

func (c *Cacher) Delete(
	ctx context.Context, key string, out runtime.Object, preconditions *storage.Preconditions,
	validateDeletion storage.ValidateObjectFunc, _ runtime.Object) error

Delete implements storage.Interface.

func (*Cacher) Get

func (c *Cacher) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error

Get implements storage.Interface.

func (*Cacher) GetList

func (c *Cacher) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error

GetList implements storage.Interface

func (*Cacher) GuaranteedUpdate

func (c *Cacher) GuaranteedUpdate(
	ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool,
	preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, _ runtime.Object) error

GuaranteedUpdate implements storage.Interface.

func (*Cacher) LastSyncResourceVersion

func (c *Cacher) LastSyncResourceVersion() (uint64, error)

LastSyncResourceVersion returns resource version to which the underlying cache is synced.

func (*Cacher) RequestWatchProgress

func (c *Cacher) RequestWatchProgress(ctx context.Context) error

func (*Cacher) Stop

func (c *Cacher) Stop()

Stop implements the graceful termination.

func (*Cacher) Versioner

func (c *Cacher) Versioner() storage.Versioner

Versioner implements storage.Interface.

func (*Cacher) Watch

func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)

Watch implements storage.Interface.

type Config

type Config struct {
	// An underlying storage.Interface.
	Storage storage.Interface

	// An underlying storage.Versioner.
	Versioner storage.Versioner

	// The GroupResource the cacher is caching. Used for disambiguating *unstructured.Unstructured (CRDs) in logging
	// and metrics.
	GroupResource schema.GroupResource

	// The Cache will be caching objects of a given Type and assumes that they
	// are all stored under ResourcePrefix directory in the underlying database.
	ResourcePrefix string

	// KeyFunc is used to get a key in the underlying storage for a given object.
	KeyFunc func(runtime.Object) (string, error)

	// GetAttrsFunc is used to get object labels, fields
	GetAttrsFunc func(runtime.Object) (label labels.Set, field fields.Set, err error)

	// IndexerFuncs is used for optimizing amount of watchers that
	// needs to process an incoming event.
	IndexerFuncs storage.IndexerFuncs

	// Indexers is used to accelerate the list operation, falls back to regular list
	// operation if no indexer found.
	Indexers *cache.Indexers

	// NewFunc is a function that creates new empty object storing a object of type Type.
	NewFunc func() runtime.Object

	// NewList is a function that creates new empty object storing a list of
	// objects of type Type.
	NewListFunc func() runtime.Object

	Codec runtime.Codec

	Clock clock.WithTicker
}

Config contains the configuration for a given Cache.

type TickerFactory

type TickerFactory interface {
	NewTicker(time.Duration) clock.Ticker
}

type WatchProgressRequester

type WatchProgressRequester func(ctx context.Context) error

Source Files

cache_watcher.go cacher.go caching_object.go lister_watcher.go ready.go time_budget.go util.go watch_cache.go watch_cache_interval.go watch_progress.go

Directories

PathSynopsis
pkg/storage/cacher/metrics
Version
v0.28.13
Published
Aug 15, 2024
Platform
js/wasm
Imports
39 packages
Last checked
1 second ago

Tools for package owners.