Documentation
¶
Overview ¶
Package managedcache implements dynamic cache management to deal with RBAC separation and stopping of informers when they are no longer needed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accessor ¶
type Accessor interface { client.Writer TrackingCache }
Accessor provides write and cached read access to the cluster.
type ConfigMapperFunc ¶
type ConfigMapperFunc[T refType] func( context.Context, T, *rest.Config, cache.Options) (*rest.Config, cache.Options, error)
ConfigMapperFunc applies changes to rest.Config and cache.Options based on the given object.
type ObjectBoundAccessManager ¶
type ObjectBoundAccessManager[T refType] interface { manager.Runnable // Get returns a TrackingCache for the provided object if one exists. // If one does not exist, a new Cache is created and returned. Get(context.Context, T) (Accessor, error) // GetWithUser returns a TrackingCache for the provided object if one exist. // If one does not exist, a new Cache is created and returned. // The additional user and usedFor parameters are used to automatically // stop informers for objects that are no longer watched. // After all users have called .FreeWithUser(), the cache itself will be stopped. GetWithUser( ctx context.Context, owner T, user client.Object, usedFor []client.Object, ) (Accessor, error) // Free will stop and remove a TrackingCache for // the provided object, if one exists. Free(context.Context, T) error // FreeWithUser informs the manager that the given user no longer needs // a cache scoped to owner T. If the cache has no active users, it will be stopped. FreeWithUser(ctx context.Context, owner T, user client.Object) error // Source returns a controller-runtime source to watch from a controller. Source(handler.EventHandler, ...predicate.Predicate) source.Source }
ObjectBoundAccessManager manages caches and clients bound to objects. Each object instance will receive it's own cache and client instance.
func NewObjectBoundAccessManager ¶
func NewObjectBoundAccessManager[T refType]( log logr.Logger, mapConfig ConfigMapperFunc[T], baseRestConfig *rest.Config, baseCacheOptions cache.Options, ) ObjectBoundAccessManager[T]
NewObjectBoundAccessManager returns a new ObjectBoundAccessManager for T.
type TrackingCache ¶
type TrackingCache interface { cache.Cache // Source returns a source to watch from a controller. Source(handler handler.EventHandler, predicates ...predicate.Predicate) source.Source // RemoveOtherInformers stops all informers that are not needed to watch the given list of object types. RemoveOtherInformers(ctx context.Context, gvks ...schema.GroupVersionKind) error }
TrackingCache is a cache remembering what objects are being cached and allowing to stop caches no longer needed.
func NewTrackingCache ¶
func NewTrackingCache(log logr.Logger, config *rest.Config, opts cache.Options) (TrackingCache, error)
NewTrackingCache returns a new TrackingCache instance.