informer

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidColumn = errors.New("supplied column is invalid")
)

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 ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, string, error)
}

type Filter

type Filter struct {
	Field   []string
	Matches []string
	Op      Op
	Partial bool
}

Filter represents a field to filter by. A subfield in an object is represented in a request query using . notation, e.g. 'metadata.name'. The subfield is internally represented as a slice, e.g. [metadata, name]. Complex subfields need to be expressed with square brackets, as in `metadata.labels[zombo.com/moose]`, but are mapped to the string slice ["metadata", "labels", "zombo.com/moose"]

If more than one value is given for the `Match` field, we do an "IN (<values>)" test

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 transaction.Client) 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, transform cache.TransformFunc, gvk schema.GroupVersionKind, db db.Client, shouldEncrypt bool, namespaced bool, watchable bool) (*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 ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, 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 continue token, if there are more pages after the returned one
  • an error instead of all of the above if anything went wrong

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, fields [][]string, s Store, namespaced bool) (*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. Fields are specified as slices (e.g. "metadata.resourceVersion" is ["metadata", "resourceVersion"])

func (*ListOptionIndexer) ListByOptions

func (l *ListOptionIndexer) ListByOptions(ctx context.Context, lo ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, 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 continue token, if there are more pages after the returned one
  • an error instead of all of the above if anything went wrong

type ListOptions

type ListOptions struct {
	ChunkSize  int
	Resume     string
	Filters    []OrFilter
	Sort       Sort
	Pagination Pagination
}

ListOptions represents the query parameters that may be included in a list request.

type Op

type Op string
const (
	Eq        Op = "="
	NotEq     Op = "!="
	Exists    Op = "Exists"
	NotExists Op = "NotExists"
	In        Op = "In"
	NotIn     Op = "NotIn"
	Lt        Op = "Lt"
	Gt        Op = "Gt"
)

type OrFilter

type OrFilter struct {
	Filters []Filter
}

OrFilter represents a set of possible fields to filter by, where an item may match any filter in the set to be included in the result.

type Pagination

type Pagination struct {
	PageSize int
	Page     int
}

Pagination represents how to return paginated results.

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 Sort

type Sort struct {
	Fields [][]string
	Orders []SortOrder
}

Sort represents the criteria to sort on. The subfield to sort by is represented in a request query using . notation, e.g. 'metadata.name'. The subfield is internally represented as a slice, e.g. [metadata, name]. The order is represented by prefixing the sort key by '-', e.g. sort=-metadata.name. e.g. To sort internal clusters first followed by clusters in alpha order: sort=-spec.internal,spec.displayName

type SortOrder

type SortOrder int

SortOrder represents whether the list should be ascending or descending.

const (
	// ASC stands for ascending order.
	ASC SortOrder = iota
	// DESC stands for descending (reverse) order.
	DESC
)

type Store

type Store interface {
	db.Client
	cache.Store

	GetByKey(key string) (item any, exists bool, err error)
	GetName() string
	RegisterAfterUpsert(f func(key string, obj any, tx transaction.Client) error)
	RegisterAfterDelete(f func(key string, tx transaction.Client) error)
	GetShouldEncrypt() bool
	GetType() reflect.Type
}

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.

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