differ

package
v0.0.0-...-4d19ac6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultClusterObjectKey

func DefaultClusterObjectKey(obj metav1.Object, ownerCluster string) string

func DefaultDifferFilter

func DefaultDifferFilter(knownClusterSet sets.String) func(obj ClusterObject) bool

Types

type ClusterObject

type ClusterObject struct {
	client.Object
	Key          string
	OwnerCluster string
}

func (ClusterObject) GetOwnerCluster

func (c ClusterObject) GetOwnerCluster() string

type Differ

type Differ interface {
	Insert(object ...ClusterObject)
	Has(object ClusterObject) bool
	Get(key string) ClusterObject
	Len() int
	Delete(object ClusterObject)
	Clear()
	GetKeys() sets.String
	// Difference compute the different keys between caller and callee.
	// receive a handler and execute to keep consistent with caller.
	Difference(Differ, Handler)
}

func NewDiffSet

func NewDiffSet(objects ...ClusterObject) Differ

type FilteringHandler

type FilteringHandler struct {
	FilterFunc func(obj ClusterObject) bool
	Handler    Handler
}

FilteringHandler applies the provided filter to all events coming in. If any object match the filter, will skip this func.

func (FilteringHandler) OnAdd

func (h FilteringHandler) OnAdd(obj ClusterObject)

OnAdd calls the nested handler only if the filter succeeds

func (FilteringHandler) OnDelete

func (h FilteringHandler) OnDelete(obj ClusterObject)

OnDelete calls the nested handler only if the filter succeeds

func (FilteringHandler) OnUpdate

func (h FilteringHandler) OnUpdate(obj1, obj2 ClusterObject)

OnUpdate calls the nested handler only if both match the filter.

type Handler

type Handler interface {
	OnAdd(obj ClusterObject)
	OnDelete(obj ClusterObject)
	OnUpdate(obj1, obj2 ClusterObject)
}

type HandlerFuncs

type HandlerFuncs struct {
	AddFunc    func(obj ClusterObject)
	DeleteFunc func(obj ClusterObject)
	UpdateFunc func(obj1, obj2 ClusterObject)
}

HandlerFuncs is an adaptor to let you easily specify as many or as few of the handle functions as you want while still implementing Handler.

func (HandlerFuncs) OnAdd

func (h HandlerFuncs) OnAdd(obj ClusterObject)

OnAdd calls AddFunc if it's not nil.

func (HandlerFuncs) OnDelete

func (h HandlerFuncs) OnDelete(obj ClusterObject)

OnDelete calls DeleteFunc if it's not nil.

func (HandlerFuncs) OnUpdate

func (h HandlerFuncs) OnUpdate(obj1, obj2 ClusterObject)

OnUpdate calls UpdateFunc if it's not nil.

Jump to

Keyboard shortcuts

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