collector

package
v0.36.0-flux.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListenerResult

type ListenerResult struct {
	Err error
}

ListenerResult is the type of the object passed back to the caller to Listen and ListenWithObserver if a fatal error has been encountered.

type Observation

type Observation struct {
	LastEventType event.Type

	ResourceStatuses []*event.ResourceStatus

	Error error
}

Observation contains the latest state known by the collector as returned by a call to the LatestObservation function.

type Observer

type Observer interface {
	Notify(*ResourceStatusCollector, event.Event)
}

Observer is an interface that can be implemented to have the ResourceStatusCollector invoke the function on every event that comes through the eventChannel. The callback happens in the processing goroutine and while the goroutine holds the lock, so any processing in the callback must be done quickly.

type ObserverFunc

type ObserverFunc func(*ResourceStatusCollector, event.Event)

ObserverFunc is a function implementation of the Observer interface.

func (ObserverFunc) Notify

func (o ObserverFunc) Notify(rsc *ResourceStatusCollector, e event.Event)

type ResourceStatusCollector

type ResourceStatusCollector struct {
	LastEventType event.Type

	ResourceStatuses map[object.ObjMetadata]*event.ResourceStatus

	Error error
	// contains filtered or unexported fields
}

ResourceStatusCollector is for use by clients of the polling library and provides a way to keep track of the latest status/state for all the polled resources. The collector is set up to listen to the eventChannel and keep the latest event for each resource. It also provides a way to fetch the latest state for all resources and the aggregated status at any point. The functions already handles synchronization so it can be used by multiple goroutines.

func NewResourceStatusCollector

func NewResourceStatusCollector(identifiers object.ObjMetadataSet) *ResourceStatusCollector

func (*ResourceStatusCollector) LatestObservation

func (o *ResourceStatusCollector) LatestObservation() *Observation

LatestObservation returns an Observation instance, which contains the latest information about the resources known by the collector.

func (*ResourceStatusCollector) Listen

func (o *ResourceStatusCollector) Listen(eventChannel <-chan event.Event) <-chan ListenerResult

Listen kicks off the goroutine that will listen for the events on the eventChannel. It returns a channel that will be closed the collector stops listening to the eventChannel.

func (*ResourceStatusCollector) ListenWithObserver

func (o *ResourceStatusCollector) ListenWithObserver(eventChannel <-chan event.Event,
	observer Observer) <-chan ListenerResult

ListenWithObserver kicks off the goroutine that will listen for the events on the eventChannel. It returns a channel that will be closed the collector stops listening to the eventChannel. The provided observer will be invoked on every event, after the event has been processed.

Jump to

Keyboard shortcuts

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