cache

package
v0.7.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPollIntervalSeconds = 120

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Start will start the cache's tick/watch mechanism
	Start(ctx context.Context)
	// Stop will stop the cache's ticker
	Stop()
	// ForceRefresh will make the watcher refresh the cache immediately
	ForceRefresh()
	// List will return the objects from the cache. The returned value is
	// an interface{} which MUST be type-checked by the caller.
	List() interface{}
}

Cache is the interface for each cache in the container's collection

type CacheCollection

type CacheCollection []cacheInfo

CacheCollection is a list of cache info held in the container.

func With

func With(l logr.Logger, cachesFn CachesFunc) CacheCollection

With adds caches to the collection

type CacheNotFoundErr

type CacheNotFoundErr struct {
	Cache StorageType
}

CacheNotFoundErr cache cannot be found in the collection

func (CacheNotFoundErr) Error

func (e CacheNotFoundErr) Error() string

type CachesFunc

type CachesFunc func() (bool, []WithCacheFunc)

CachesFunc is a helper wrapper to set whether caches should be synced.

func WithSimpleCaches

func WithSimpleCaches(opts ...WithCacheFunc) CachesFunc

WithSimpleCaches will return false and resulting caches will work independently of each other

func WithSyncedCaches

func WithSyncedCaches(opts ...WithCacheFunc) CachesFunc

WithSyncedCaches will return true and configure resulting caches with a sync channel

type Container

type Container interface {
	Start(ctx context.Context)
	Stop()
	ForceRefresh(name StorageType) error
	List(name StorageType) (interface{}, error)
}

func NewContainer

func NewContainer(logger logr.Logger, cachesFn CachesFunc) Container

NewContainer returns a new cache container. The caches in the container will be built up from the list of opts. If already set, the globalCacheContainer will be returned. Otherwise the new container will be set as the globalCacheContainer which, as the name suggests, will be made globally available.

type StorageType

type StorageType string

StorageType is the name of the cache, eg NamespaceStorage

const NamespaceStorage StorageType = "namespace"

type WithCacheFunc

type WithCacheFunc func(logr.Logger, chan mngr.Cluster) (StorageType, Cache)

WithCacheFunc returns a storage name and an implementor of the Cache interface to be added to the container's cache collection

func WithNamespaceCache

func WithNamespaceCache(cfg *rest.Config) WithCacheFunc

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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