manager

package
v1.0.1-0...-5dc2c13 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetObjectFunc

type GetObjectFunc func(string, string, metav1.GetOptions) (runtime.Object, error)

GetObjectFunc defines a function to get object with a given namespace and name.

type GetObjectTTLFunc

type GetObjectTTLFunc func() (time.Duration, bool)

GetObjectTTLFunc defines a function to get value of TTL.

func GetObjectTTLFromNodeFunc

func GetObjectTTLFromNodeFunc(getNode func() (*v1.Node, error)) GetObjectTTLFunc

GetObjectTTLFromNodeFunc returns a function that returns TTL value from a given Node object.

type Manager

type Manager interface {
	// Get object by its namespace and name.
	GetObject(namespace, name string) (runtime.Object, error)

	// RegisterPod registers all objects referenced from a given pod.
	RegisterPod(pod *v1.Pod)

	// UnregisterPod unregisters objects referenced from a given pod that are not
	// used by any other registered pod.
	UnregisterPod(pod *v1.Pod)
}

Manager is the interface for registering and unregistering objects referenced by pods in the underlying cache and extracting those from that cache if needed.

func NewCacheBasedManager

func NewCacheBasedManager(objectStore Store, getReferencedObjects func(*v1.Pod) sets.String) Manager

NewCacheBasedManager creates a manager that keeps a cache of all objects necessary for registered pods. It implements the following logic:

  • whenever a pod is created or updated, the cached versions of all objects is is referencing are invalidated
  • every GetObject() call tries to fetch the value from local cache; if it is not there, invalidated or too old, we fetch it from apiserver and refresh the value in cache; otherwise it is just fetched from cache

func NewWatchBasedManager

func NewWatchBasedManager(listObject listObjectFunc, watchObject watchObjectFunc, newObject newObjectFunc, groupResource schema.GroupResource, getReferencedObjects func(*v1.Pod) sets.String) Manager

NewWatchBasedManager creates a manager that keeps a cache of all objects necessary for registered pods. It implements the following logic:

  • whenever a pod is created or updated, we start individual watches for all referenced objects that aren't referenced from other registered pods
  • every GetObject() returns a value from local cache propagated via watches

type Store

type Store interface {
	// AddReference adds a reference to the object to the store.
	// Note that multiple additions to the store has to be allowed
	// in the implementations and effectively treated as refcounted.
	AddReference(namespace, name string)
	// DeleteReference deletes reference to the object from the store.
	// Note that object should be deleted only when there was a
	// corresponding Delete call for each of Add calls (effectively
	// when refcount was reduced to zero).
	DeleteReference(namespace, name string)
	// Get an object from a store.
	Get(namespace, name string) (runtime.Object, error)
}

Store is the interface for a object cache that can be used by cacheBasedManager.

func NewObjectCache

func NewObjectCache(listObject listObjectFunc, watchObject watchObjectFunc, newObject newObjectFunc, groupResource schema.GroupResource) Store

NewObjectCache returns a new watch-based instance of Store interface.

func NewObjectStore

func NewObjectStore(getObject GetObjectFunc, clock clock.Clock, getTTL GetObjectTTLFunc, ttl time.Duration) Store

NewObjectStore returns a new ttl-based instance of Store interface.

Jump to

Keyboard shortcuts

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