factory

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Overview

Package factory provides a cache factory for the sql-based cache.

Index

Constants

View Source
const EncryptAllEnvVar = "CATTLE_ENCRYPT_CACHE_ALL"

EncryptAllEnvVar is set to "true" if users want all types' data blobs to be encrypted in SQLite otherwise only variables in defaultEncryptedResourceTypes will have their blobs encrypted

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	informer.ByOptionsLister
	// contains filtered or unexported fields
}

func (*Cache) Context added in v0.6.43

func (c *Cache) Context() context.Context

Context gives the context of the factory that created this cache.

The context is canceled when the cache is stopped (eg: when the CRD column definition changes)

func (*Cache) GVK added in v0.6.40

func (c *Cache) GVK() schema.GroupVersionKind

type CacheFactory

type CacheFactory struct {
	// contains filtered or unexported fields
}

CacheFactory builds Informer instances and keeps a cache of instances it created

func NewCacheFactory

func NewCacheFactory(opts CacheFactoryOptions) (*CacheFactory, error)

NewCacheFactory returns an informer factory instance This is currently called from steve via initial calls to `s.cacheFactory.CacheFor(...)`

func NewCacheFactoryWithContext added in v0.6.43

func NewCacheFactoryWithContext(ctx context.Context, opts CacheFactoryOptions) (*CacheFactory, error)

func (*CacheFactory) CacheFor

func (f *CacheFactory) CacheFor(ctx context.Context, fields [][]string, externalUpdateInfo *sqltypes.ExternalGVKUpdates, selfUpdateInfo *sqltypes.ExternalGVKUpdates, transform cache.TransformFunc, client dynamic.ResourceInterface, gvk schema.GroupVersionKind, typeGuidance map[string]string, namespaced bool, watchable bool) (*Cache, error)

CacheFor returns an informer for given GVK, using sql store indexed with fields, using the specified client. For virtual fields, they must be added by the transform function and specified by fields to be used for later fields.

There's a few context.Context involved. Here's the hierarchy:

  • ctx is the context of a request (eg: net/http.Request.Context). It is canceled when the request finishes (eg: the client timed out or canceled the request)
  • [CacheFactory.ctx] is the context for the cache factory. This is canceled when we no longer need the cache factory
  • [guardedInformer.ctx] is the context for a single cache. Its parent is the [CacheFactory.ctx] so that all caches stops when the cache factory stop. We need a context for a single cache to be able to stop that cache (eg: on schema refresh) without impacting the other caches.

Don't forget to call DoneWithCache with the given informer once done with it.

func (*CacheFactory) DoneWithCache added in v0.6.39

func (f *CacheFactory) DoneWithCache(cache *Cache)

DoneWithCache must be called for every successful CacheFor call. The Cache should no longer be used after DoneWithCache is called.

This ensures that there aren't any inflight list requests while we are resetting the database.

func (*CacheFactory) Stop added in v0.6.39

Stop cancels ctx which stops any running informers, assigns a new ctx, resets the GVK-informer cache, and resets the database connection which wipes any current sqlite database at the default location.

type CacheFactoryOptions added in v0.6.9

type CacheFactoryOptions struct {
	// GCInterval is how often to run the garbage collection
	GCInterval time.Duration
	// GCKeepCount is how many events to keep in _events table when gc runs
	GCKeepCount int
}

Jump to

Keyboard shortcuts

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