informer

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: 30 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidColumn   = errors.New("supplied column is invalid")
	ErrTooOld          = errors.New("resourceversion too old")
	ErrUnknownRevision = errors.New("unknown revision")
)

Functions

func SetSyntheticWatchableInterval added in v0.5.7

func SetSyntheticWatchableInterval(interval time.Duration)

SetSyntheticWatchableInterval - call this function to override the default interval time of 5 seconds

func UnsafeGet

func UnsafeGet(object any, field string) any

UnsafeGet returns the value of the passed object's for the passed field.

func UnsafeSet

func UnsafeSet(object any, field string, value any)

UnsafeSet replaces the passed object's field value with the passed value.

Types

type ByOptionsLister

type ByOptionsLister interface {
	ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, *types.APISummary, string, error)
	Watch(ctx context.Context, options WatchOptions, eventsCh chan<- watch.Event) error
	GetLatestResourceVersion() []string
	RunGC(context.Context)
	DropAll(context.Context) error
}

type Indexer

type Indexer struct {
	Store
	// contains filtered or unexported fields
}

Indexer is a SQLite-backed cache.Indexer which builds upon Store adding an index table

func NewIndexer

func NewIndexer(ctx context.Context, indexers cache.Indexers, s Store) (*Indexer, error)

NewIndexer returns a cache.Indexer backed by SQLite for objects of the given example type

func (*Indexer) AddIndexers

func (i *Indexer) AddIndexers(newIndexers cache.Indexers) error

AddIndexers adds more indexers to this Store. If you call this after you already have data in the Store, the results are undefined.

func (*Indexer) AfterUpsert

func (i *Indexer) AfterUpsert(key string, obj any, tx db.TxClient) error

AfterUpsert updates indices of an object

func (*Indexer) ByIndex

func (i *Indexer) ByIndex(indexName, indexedValue string) ([]any, error)

ByIndex returns the stored objects whose set of indexed values for the named index includes the given indexed value

func (*Indexer) GetIndexers

func (i *Indexer) GetIndexers() cache.Indexers

GetIndexers returns the indexers

func (*Indexer) Index

func (i *Indexer) Index(indexName string, obj any) (result []any, err error)

Index returns a list of items that match the given object on the index function

func (*Indexer) IndexKeys

func (i *Indexer) IndexKeys(indexName, indexedValue string) ([]string, error)

IndexKeys returns a list of the Store keys of the objects whose indexed values in the given index include the given indexed value

func (*Indexer) ListIndexFuncValues

func (i *Indexer) ListIndexFuncValues(name string) []string

ListIndexFuncValues wraps safeListIndexFuncValues and panics in case of I/O errors

type Informer

type Informer struct {
	cache.SharedIndexInformer
	ByOptionsLister
}

Informer is a SQLite-backed cache.SharedIndexInformer that can execute queries on listprocessor structs

func NewInformer

func NewInformer(ctx context.Context, client dynamic.ResourceInterface, fields [][]string, externalUpdateInfo *sqltypes.ExternalGVKUpdates, selfUpdateInfo *sqltypes.ExternalGVKUpdates, transform cache.TransformFunc, gvk schema.GroupVersionKind, db db.Client, shouldEncrypt bool,
	typeGuidance map[string]string, namespaced bool, watchable bool, gcInterval time.Duration, gcKeepCount int) (*Informer, error)

NewInformer returns a new SQLite-backed Informer for the type specified by schema in unstructured.Unstructured form using the specified client

func (*Informer) ListByOptions

func (i *Informer) ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, *types.APISummary, string, error)

ListByOptions returns objects according to the specified list options and partitions. Specifically:

  • an unstructured list of resources belonging to any of the specified partitions
  • the total number of resources (returned list might be a subset depending on pagination options in lo)
  • a summary object, containing the possible values for each field specified in a summary= subquery
  • a continue token, if there are more pages after the returned one
  • an error instead of all of the above if anything went wrong

func (*Informer) Run added in v0.6.39

func (i *Informer) Run(stopCh <-chan struct{})

Run implements cache.SharedIndexInformer

func (*Informer) RunWithContext added in v0.6.39

func (i *Informer) RunWithContext(ctx context.Context)

RunWithContext implements cache.SharedIndexInformer

type ListOptionIndexer

type ListOptionIndexer struct {
	*Indexer
	// contains filtered or unexported fields
}

ListOptionIndexer extends Indexer by allowing queries based on ListOption

func NewListOptionIndexer

func NewListOptionIndexer(ctx context.Context, s Store, opts ListOptionIndexerOptions) (*ListOptionIndexer, error)

NewListOptionIndexer returns a SQLite-backed cache.Indexer of unstructured.Unstructured Kubernetes resources of a certain GVK ListOptionIndexer is also able to satisfy ListOption queries on indexed (sub)fields.

func (*ListOptionIndexer) GetLatestResourceVersion added in v0.6.29

func (l *ListOptionIndexer) GetLatestResourceVersion() []string

func (*ListOptionIndexer) ListByOptions

func (l *ListOptionIndexer) ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (list *unstructured.UnstructuredList, total int, summary *types.APISummary, continueToken string, err error)

ListByOptions returns objects according to the specified list options and partitions. Specifically:

  • an unstructured list of resources belonging to any of the specified partitions
  • the total number of resources (returned list might be a subset depending on pagination options in lo)
  • a summary object, containing the possible values for each field specified in a summary= subquery
  • a continue token, if there are more pages after the returned one
  • an error instead of all of the above if anything went wrong

func (*ListOptionIndexer) ListSummaryFields added in v0.8.1

func (l *ListOptionIndexer) ListSummaryFields(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, dbName string, namespace string) (*types.APISummary, error)

func (*ListOptionIndexer) ListSummaryForField added in v0.8.1

func (l *ListOptionIndexer) ListSummaryForField(ctx context.Context, field []string, fieldNum int, dbName string, filterComponents *filterComponentsT, mainFieldPrefix string, joinTableIndexByLabelName map[string]int) (map[string]any, error)

func (*ListOptionIndexer) RunGC added in v0.6.39

func (l *ListOptionIndexer) RunGC(ctx context.Context)

func (*ListOptionIndexer) Watch added in v0.6.7

func (l *ListOptionIndexer) Watch(ctx context.Context, opts WatchOptions, eventsCh chan<- watch.Event) error

type ListOptionIndexerOptions added in v0.6.9

type ListOptionIndexerOptions struct {
	// Fields is a list of fields within the object that we want indexed for
	// filtering & sorting. Each field is specified as a slice.
	//
	// For example, .metadata.resourceVersion should be specified as []string{"metadata", "resourceVersion"}
	Fields [][]string
	// Used for specifying types of non-TEXT database fields.
	// The key is a fully-qualified field name, like 'metadata.fields[1]'.
	// The value is a type name, most likely "INT" but could be "REAL". The default type is "TEXT",
	// and we don't (currently) use NULL or BLOB types.
	TypeGuidance map[string]string
	// IsNamespaced determines whether the GVK for this ListOptionIndexer is
	// namespaced
	IsNamespaced bool
	// 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
}

type QueryInfo added in v0.5.4

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

QueryInfo is a helper-struct that is used to represent the core query and parameters when converting a filter from the UI into a sql query

type Store

type Store interface {
	db.Client
	cache.Store

	GetByKey(key string) (item any, exists bool, err error)
	GetName() string
	RegisterAfterAdd(f func(key string, obj any, tx db.TxClient) error)
	RegisterAfterUpdate(f func(key string, obj any, tx db.TxClient) error)
	RegisterAfterDelete(f func(key string, obj any, tx db.TxClient) error)
	RegisterAfterDeleteAll(f func(tx db.TxClient) error)
	RegisterBeforeDropAll(f func(tx db.TxClient) error)
	GetShouldEncrypt() bool
	GetType() reflect.Type
	DropAll(ctx context.Context) error
}

type SyntheticWatcher added in v0.5.7

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

func (*SyntheticWatcher) Done added in v0.5.7

func (rw *SyntheticWatcher) Done() <-chan struct{}

func (*SyntheticWatcher) ResultChan added in v0.5.7

func (rw *SyntheticWatcher) ResultChan() <-chan watch.Event

ResultChan implements k8s.io/apimachinery/pkg/watch.Interface.

func (*SyntheticWatcher) Stop added in v0.5.7

func (rw *SyntheticWatcher) Stop()

Stop implements k8s.io/apimachinery/pkg/watch.Interface.

type WatchFilter added in v0.6.7

type WatchFilter struct {
	ID        string
	Selector  labels.Selector
	Namespace string
}

type WatchOptions added in v0.6.7

type WatchOptions struct {
	ResourceVersion string
	Filter          WatchFilter
}

Directories

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

Jump to

Keyboard shortcuts

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