informerutil

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwapMapReplace

func SwapMapReplace[K comparable, V any, U any](m *SwapMap[K, V], values map[K]U, transformValue func(U) V) map[K]SwapResult[V]

Types

type Decayed

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

func DecayedOf

func DecayedOf[V metav1.Object](obj V) *Decayed

type DecayingInformer

type DecayingInformer[V metav1.Object] struct {
	// contains filtered or unexported fields
}

DecayingInformer is an informer that only supports delta handling. It still handles Replace logic (i.e. relisting) properly, but the reference to the object (other than the metadata) is released once the handler is called.

func NewDecayingInformer

func NewDecayingInformer[V metav1.Object]() *DecayingInformer[V]

func (*DecayingInformer[V]) Add

func (di *DecayingInformer[V]) Add(obj any) error

func (*DecayingInformer[V]) Delete

func (di *DecayingInformer[V]) Delete(obj any) error

func (*DecayingInformer[V]) Get

func (di *DecayingInformer[V]) Get(obj any) (any, bool, error)

func (*DecayingInformer[V]) GetByKey

func (di *DecayingInformer[V]) GetByKey(key string) (any, bool, error)

func (*DecayingInformer[V]) List

func (di *DecayingInformer[V]) List() []any

func (*DecayingInformer[V]) ListKeys

func (di *DecayingInformer[V]) ListKeys() []string

func (*DecayingInformer[V]) Replace

func (di *DecayingInformer[V]) Replace(list []any, resourceVersion string) error

func (*DecayingInformer[V]) Resync

func (di *DecayingInformer[V]) Resync() error

func (*DecayingInformer[V]) SetAddCh

func (di *DecayingInformer[V]) SetAddCh() <-chan V

func (*DecayingInformer[V]) SetRemoveCh

func (di *DecayingInformer[V]) SetRemoveCh() <-chan *Decayed

func (*DecayingInformer[V]) SetReplaceCh

func (di *DecayingInformer[V]) SetReplaceCh() <-chan V

func (*DecayingInformer[V]) Update

func (di *DecayingInformer[V]) Update(obj any) error

type ObjectKey

type ObjectKey struct {
	Namespace string
	Name      string
}

func ObjectKeyOf

func ObjectKeyOf[V metav1.Object](object V) ObjectKey

type PrepushUndeltaStore

type PrepushUndeltaStore[V metav1.Object] struct {
	OnAdd         func(newObj V)
	OnUpdate      func(oldObj, newObj V)
	OnDelete      func(oldObj V)
	OnPostReplace func()
	// contains filtered or unexported fields
}

func NewPrepushUndeltaStore

func NewPrepushUndeltaStore[V metav1.Object](
	logger logrus.FieldLogger,
	objectFilter func(obj V) bool,
) *PrepushUndeltaStore[V]

func (*PrepushUndeltaStore[V]) Add

func (store *PrepushUndeltaStore[V]) Add(obj any) error

func (*PrepushUndeltaStore[V]) Delete

func (store *PrepushUndeltaStore[V]) Delete(obj any) error

func (*PrepushUndeltaStore[V]) Get

func (store *PrepushUndeltaStore[V]) Get(obj any) (any, bool, error)

func (*PrepushUndeltaStore[V]) GetByKey

func (store *PrepushUndeltaStore[V]) GetByKey(key string) (any, bool, error)

func (*PrepushUndeltaStore[V]) List

func (store *PrepushUndeltaStore[V]) List() []any

func (*PrepushUndeltaStore[V]) ListKeys

func (store *PrepushUndeltaStore[V]) ListKeys() []string

func (*PrepushUndeltaStore[V]) Replace

func (store *PrepushUndeltaStore[V]) Replace(list []any, resourceVersion string) error

func (*PrepushUndeltaStore[V]) Resync

func (store *PrepushUndeltaStore[V]) Resync() error

func (*PrepushUndeltaStore[V]) Update

func (store *PrepushUndeltaStore[V]) Update(obj any) error

type SwapMap

type SwapMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SwapMap is a thread-safe map that provides atomic swapping results, optimized to be used as an informer backend with no read operations.

func NewSwapMap

func NewSwapMap[K comparable, V any](capacity int) *SwapMap[K, V]

func (*SwapMap[K, V]) Swap

func (m *SwapMap[K, V]) Swap(key K, newValue V, hasNewValue bool) SwapResult[V]

func (*SwapMap[K, V]) SwapIf

func (m *SwapMap[K, V]) SwapIf(
	key K,
	newValue V,
	hasNewValue bool,
	shouldSwap func(oldValue, newValue V) bool,
) SwapResult[V]

SwapIf swaps newValue with m[key] unless both values exist and condition(m[key], newValue) is false.

type SwapResult

type SwapResult[V any] struct {
	Kind SwapResultKind
	// OldValue is the original value if Kind is Remove or Replace
	OldValue V
	// NewValue is the new value if Kind is Add or Replace
	NewValue V
}

type SwapResultKind

type SwapResultKind uint8
const (
	SwapResultKindNoop SwapResultKind = iota
	SwapResultKindAdd
	SwapResultKindRemove
	SwapResultKindReplace
)

Jump to

Keyboard shortcuts

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