labelindex

package
v0.0.0-...-c0ae054 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyErrAdapter

type EmptyErrAdapter struct{}

func (EmptyErrAdapter) IsErr

func (EmptyErrAdapter) IsErr(_ util.Empty) bool

func (EmptyErrAdapter) Nil

func (EmptyErrAdapter) Nil() util.Empty

type ErrAdapter

type ErrAdapter[Err any] interface {
	IsErr(err Err) bool

	Nil() Err
}

type ErrorErrAdapter

type ErrorErrAdapter struct{}

func (ErrorErrAdapter) IsErr

func (ErrorErrAdapter) IsErr(err error) bool

func (ErrorErrAdapter) Nil

func (ErrorErrAdapter) Nil() error

type ExistedBefore

type ExistedBefore = mm.ExistedBefore

type Index

type Index[Name any, Tracked any, Query any, TrackErr any, QueryErr any] interface {
	// Starts tracking an item.
	// The state of the index is the same as before calling the method if an error is returned.
	Track(name Name, item Tracked) TrackErr

	// Stops tracking an item.
	// Returns true if the item was not tracked before.
	Untrack(name Name) ExistedBefore

	// Returns all tracked items consistent with the query.
	// Read-only operation.
	Query(query Query) (iter.Iter[Name], QueryErr)
}

type Locked

type Locked[
	Name any, Tracked any, Query any, TrackErr any, QueryErr any,
	IndexT Index[Name, Tracked, Query, TrackErr, QueryErr],
] struct {
	// contains filtered or unexported fields
}

An Index wrapper that protects read/write operations with a RWMutex.

func NewLocked

func NewLocked[
	Name any, Tracked any, Query any, TrackErr any, QueryErr any,
	IndexT Index[Name, Tracked, Query, TrackErr, QueryErr],
](index IndexT,
	queryErrAdapter ErrAdapter[QueryErr],
) *Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]

func (*Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Query

func (index *Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Query(
	query Query,
) (iter.Iter[Name], QueryErr)

Note that the index is read-locked until the iterator is fully exhausted. If the loop is time-consuming, consider collecting the result to a slice first.

func (*Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Track

func (index *Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Track(
	name Name,
	item Tracked,
) TrackErr

func (*Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Untrack

func (index *Locked[Name, Tracked, Query, TrackErr, QueryErr, IndexT]) Untrack(
	name Name,
) ExistedBefore

type Namespaced

type Namespaced[
	Tracked any, Query any, TrackErr any, QueryErr any,
	IndexT Index[string, Tracked, Query, TrackErr, QueryErr],
] struct {
	// contains filtered or unexported fields
}

Isolates each namespace with a separate Index.

func NewNamespaced

func NewNamespaced[
	Tracked any, Query any, TrackErr any, QueryErr any,
	IndexT Index[string, Tracked, Query, TrackErr, QueryErr],
](
	newIndex func() IndexT,
	queryErrAdapter ErrAdapter[QueryErr],
) *Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]

func (*Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Query

func (index *Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Query(
	query NamespacedQuery[Query],
) (iter.Iter[types.NamespacedName], QueryErr)

func (*Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Track

func (index *Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Track(
	name types.NamespacedName,
	item Tracked,
) TrackErr

func (*Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Untrack

func (index *Namespaced[Tracked, Query, TrackErr, QueryErr, IndexT]) Untrack(
	name types.NamespacedName,
) ExistedBefore

type NamespacedQuery

type NamespacedQuery[T any] struct {
	Namespace string
	Query     T
}

type Selectors

type Selectors[Name comparable] struct {
	// contains filtered or unexported fields
}

Stores a dictionary of label selectors.

func NewSelectors

func NewSelectors[Name comparable]() *Selectors[Name]

func (*Selectors[Name]) Query

func (indexer *Selectors[Name]) Query(rawSet map[string]string) (iter.Iter[Name], util.Empty)

func (*Selectors[Name]) Track

func (indexer *Selectors[Name]) Track(name Name, rawSelector metav1.LabelSelector) error

Start tracking a selector or update an existing one with the same name. The selector object must be immutable.

func (*Selectors[Name]) Untrack

func (indexer *Selectors[Name]) Untrack(name Name) ExistedBefore

Stop tracking a selector if it exists.

type Sets

type Sets[Name comparable] struct {
	// contains filtered or unexported fields
}

Maintains an index of known label sets. Efficiently queries the names of sets matching a selector.

func NewSets

func NewSets[Name comparable]() *Sets[Name]

func (*Sets[Name]) Query

func (indexer *Sets[Name]) Query(rawSelector metav1.LabelSelector) (iter.Iter[Name], error)

func (*Sets[Name]) Track

func (indexer *Sets[Name]) Track(name Name, set map[string]string) util.Empty

func (*Sets[Name]) Untrack

func (indexer *Sets[Name]) Untrack(name Name) ExistedBefore

Directories

Path Synopsis
MultiMap types.
MultiMap types.
Implements a modified version of SetTrie that acts like a Map[Word, Data].
Implements a modified version of SetTrie that acts like a Map[Word, Data].

Jump to

Keyboard shortcuts

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