...

Package collector

import "sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector"
Overview
Index

Overview ▾

type ListenerResult

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

type ListenerResult struct {
    Err error
}

type Observation

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

type Observation struct {
    LastEventType event.Type

    ResourceStatuses []*event.ResourceStatus

    Error error
}

type Observer

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 Observer interface {
    Notify(*ResourceStatusCollector, event.Event)
}

type ObserverFunc

ObserverFunc is a function implementation of the Observer interface.

type ObserverFunc func(*ResourceStatusCollector, event.Event)

func (ObserverFunc) Notify

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

type ResourceStatusCollector

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.

type ResourceStatusCollector struct {
    LastEventType event.Type

    ResourceStatuses map[object.ObjMetadata]*event.ResourceStatus

    Error error
    // contains filtered or unexported fields
}

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.