collector

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Observation

type Observation struct {
	LastEventType event.EventType

	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 added in v0.7.0

type Observer interface {
	Notify(*ResourceStatusCollector)
}

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 added in v0.7.0

type ObserverFunc func(*ResourceStatusCollector)

ObserverFunc is a function implementation of the Observer interface.

func (ObserverFunc) Notify added in v0.7.0

func (o ObserverFunc) Notify(rsc *ResourceStatusCollector)

type ResourceStatusCollector

type ResourceStatusCollector struct {
	LastEventType event.EventType

	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.ObjMetadata) *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 struct{}

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 added in v0.7.0

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

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. 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