resourceTracker

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceFilter

type ResourceFilter[TObj kubernetes.Object] func(o TObj, err error) bool

type ResourceTracker

type ResourceTracker[TObj kubernetes.Object] interface {

	//KnownResources returns all currently known resources
	//If a filter was used to create this tracker it will be applied on the KnownResources
	KnownResources() ([]TObj, error)

	//KnownResourcesByIndex returns currently known resources with the given <indexValue> within the index <indexName>
	//If a filter was used to create this tracker it will be applied on the KnownResourcesByIndex
	KnownResourcesByIndex(indexName string, indexValue string) ([]TObj, error)

	//RegisterAddedPodHandler adds a new handler for the "Added Resource" event
	RegisterAddedPodHandler(chan TObj)
	//UnregisterAddedPodHandler removes a previously registered handler (the channel gets closed by UnregisterAddedPodHandler)
	UnregisterAddedPodHandler(chan TObj)

	//RegisterDeletedPodHandler adds a new handler for the "Deleted Resource" event
	RegisterDeletedPodHandler(chan TrackerDeleteResource[TObj])
	//UnregisterDeletedPodHandler removes a previously registered handler (the channel gets closed by UnregisterDeletedPodHandler)
	UnregisterDeletedPodHandler(chan TrackerDeleteResource[TObj])

	//RegisterUpdatedPodHandler adds a new handler for the "Updated Resource" event
	RegisterUpdatedPodHandler(chan struct{ Old, New TObj })
	//UnregisterUpdatedPodHandler removes a previously registered handler (the channel gets closed by UnregisterUpdatedPodHandler)
	UnregisterUpdatedPodHandler(chan struct{ Old, New TObj })
}

func NewResourceTracker

func NewResourceTracker[TObj kubernetes.Object](informer cache.SharedIndexInformer, filter ResourceFilter[TObj]) (ResourceTracker[TObj], error)

NewResourceTracker attaches a typed resource tracker to the given shared informer cache.SharedIndexInformer.

It's mandatory that any objects published by cache.SharedIndexInformer are convertable to [TObj] via scheme.Schema.Convert. Objects witch are not convertable lead to a log message and will not be processed further.

type TrackerDeleteResource

type TrackerDeleteResource[TObj kubernetes.Object] struct {
	Resource     TObj
	ResourceKey  string
	RawResource  interface{}
	UnknownState bool
}

TrackerDeleteResource contains information on deleted resources in the underlying cache.SharedIndexInformer. There is the possibility that k8s already "finalized" the deleted object or has some trouble to do so.

in case of a normal deletion

	TrackerDeleteResource.Resource contains a converted state
	TrackerDeleteResource.UnknownState will be false

in case of an abnormal deletion

	TrackerDeleteResource.Resource might contain a converted state; if the underlying k8s resource is still convertible; NOTE: the contents might differ from the current k8s state as the presented resource might be outdated!
	TrackerDeleteResource.UnknownState will be true
	TrackerDeleteResource.RawResource contains the raw resource from k8s; usually tha last known state of the resource when the client still was connected to k8s
	TrackerDeleteResource.ResourceKey contains the key to the abnormal deleted object; usually delivered in form of "<namespace>/<name>"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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