Documentation ¶
Index ¶
- func NewThreadSafeStore(example any, path string, indexers cache.Indexers) (cache.ThreadSafeStore, error)
- func UnsafeGet(object any, field string) any
- func UnsafeSet(object any, field string, value any)
- type FieldFunc
- type Filter
- type Indexer
- func (i *Indexer) AddIndexers(newIndexers cache.Indexers) error
- func (i *Indexer) AfterUpsert(key string, obj any, tx *sql.Tx) error
- func (i *Indexer) ByIndex(indexName, indexedValue string) ([]any, error)
- func (i *Indexer) GetIndexers() cache.Indexers
- func (i *Indexer) Index(indexName string, obj any) ([]any, error)
- func (i *Indexer) IndexKeys(indexName, indexedValue string) ([]string, error)
- func (i *Indexer) ListIndexFuncValues(name string) []string
- func (i *Indexer) SafeListIndexFuncValues(indexName string) ([]string, error)
- type ListOptionIndexer
- type ListOptions
- type Pagination
- type Sort
- type SortOrder
- type Store
- func (s *Store) Add(obj any) error
- func (s *Store) Close() error
- func (s *Store) Delete(obj any) error
- func (s *Store) DeleteByKey(key string) error
- func (s *Store) Get(obj any) (item any, exists bool, err error)
- func (s *Store) GetByKey(key string) (item any, exists bool, err error)
- func (s *Store) InitExec(stmt string) error
- func (s *Store) List() []any
- func (s *Store) ListKeys() []string
- func (s *Store) Prepare(stmt string) *sql.Stmt
- func (s *Store) QueryObjects(stmt *sql.Stmt, params ...any) ([]any, error)
- func (s *Store) QueryStrings(stmt *sql.Stmt, params ...any) ([]string, error)
- func (s *Store) RegisterAfterDelete(f func(key string, tx *sql.Tx) error)
- func (s *Store) RegisterAfterUpsert(f func(key string, obj any, tx *sql.Tx) error)
- func (s *Store) Replace(objects []any, _ string) error
- func (s *Store) ReplaceByKey(objects map[string]any) error
- func (s *Store) Resync() error
- func (s *Store) Update(obj any) error
- func (s *Store) Upsert(key string, obj any) error
- type VersionFunc
- type VersionedIndexer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewThreadSafeStore ¶
func NewThreadSafeStore(example any, path string, indexers cache.Indexers) (cache.ThreadSafeStore, error)
NewThreadSafeStore returns a cache.ThreadSafeStore backed by SQLite for the example type
Types ¶
type FieldFunc ¶
FieldFunc is a function from an object to a filterable/sortable property. Result can be string, int or bool
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
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].
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(example any, keyFunc cache.KeyFunc, path string, indexers cache.Indexers) (*Indexer, error)
NewIndexer returns a cache.Indexer backed by SQLite for objects of the given example type
func (*Indexer) AddIndexers ¶
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 ¶
AfterUpsert updates indices of an object
func (*Indexer) ByIndex ¶
ByIndex returns the stored objects whose set of indexed values for the named index includes the given indexed value
func (*Indexer) GetIndexers ¶
GetIndexers returns the indexers
func (*Indexer) Index ¶
Index returns a list of items that match the given object on the index function
func (*Indexer) IndexKeys ¶
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 ¶
ListIndexFuncValues wraps SafeListIndexFuncValues and panics in case of I/O errors
type ListOptionIndexer ¶
type ListOptionIndexer struct { *VersionedIndexer // contains filtered or unexported fields }
ListOptionIndexer extends VersionedIndexer by allowing queries based on ListOption
func NewCustomListOptionIndexer ¶
func NewCustomListOptionIndexer(example meta.Object, keyFunc cache.KeyFunc, path string, fieldFuncs map[string]FieldFunc, indexers cache.Indexers) (*ListOptionIndexer, error)
NewCustomListOptionIndexer returns a cache.Indexer on a Kubernetes resource that is also able to satisfy ListOption queries with custom keyFunc and Indexers
func NewListOptionIndexer ¶
func NewListOptionIndexer(example meta.Object, path string, fieldFuncs map[string]FieldFunc) (*ListOptionIndexer, error)
NewListOptionIndexer returns a cache.Indexer on a Kubernetes resource that is also able to satisfy ListOption queries
func (*ListOptionIndexer) AfterUpsert ¶
AfterUpsert saves sortable/filterable fields into tables
func (*ListOptionIndexer) ListByOptions ¶
func (l *ListOptionIndexer) ListByOptions(lo ListOptions) ([]any, error)
ListByOptions returns objects according to the ListOptions struct
type ListOptions ¶
type ListOptions struct { ChunkSize int Resume string Filters []Filter Sort Sort Pagination Pagination Revision string }
ListOptions represents the query parameters that may be included in a list request.
type Pagination ¶
type Pagination struct {
// contains filtered or unexported fields
}
Pagination represents how to return paginated results.
type Sort ¶
type Sort struct {
// contains filtered or unexported fields
}
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.
type SortOrder ¶
type SortOrder int
SortOrder represents whether the list should be ascending or descending.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a SQLite-backed cache.Store
func (*Store) DeleteByKey ¶
DeleteByKey deletes the object associated with key, if it exists in this Store
func (*Store) InitExec ¶
InitExec executes a statement as part of the DB initialization, closing the connection on error
func (*Store) List ¶
List returns a list of all the currently known objects Note: I/O errors will panic this function, as the interface signature does not allow returning errors
func (*Store) ListKeys ¶
ListKeys returns a list of all the keys currently in this Store Note: I/O errors will panic this function, as the interface signature does not allow returning errors
func (*Store) QueryObjects ¶
QueryObjects runs a prepared statement that returns gobbed objects of type typ
func (*Store) QueryStrings ¶
QueryStrings runs a prepared statement that returns strings
func (*Store) RegisterAfterDelete ¶
RegisterAfterDelete registers a func to be called after each deletion
func (*Store) RegisterAfterUpsert ¶
RegisterAfterUpsert registers a func to be called after each upsert
func (*Store) ReplaceByKey ¶
ReplaceByKey will delete the contents of the Store, using instead the given key to obj map
type VersionFunc ¶
type VersionedIndexer ¶
type VersionedIndexer struct { *Indexer // contains filtered or unexported fields }
VersionedIndexer extends Indexer by storing a range of versions in addition to the latest one
func NewVersionedIndexer ¶
func NewVersionedIndexer(example any, keyFunc cache.KeyFunc, versionFunc VersionFunc, path string, indexers cache.Indexers) (*VersionedIndexer, error)
NewVersionedIndexer returns an Indexer that also stores a range of versions in addition to the latest one
func (*VersionedIndexer) AfterDelete ¶
func (v *VersionedIndexer) AfterDelete(key string, tx *sql.Tx) error
AfterDelete updates the deleted flag on the history table
func (*VersionedIndexer) AfterUpsert ¶
AfterUpsert appends the latest version to the history table
func (*VersionedIndexer) GetByKeyAndVersion ¶
func (v *VersionedIndexer) GetByKeyAndVersion(key string, version int) (item any, exists bool, err error)
GetByKeyAndVersion returns the object associated with the given object's key and (exact) version