status

package module
v0.117.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 8 Imported by: 2

README

pkg/status

Status
Stability development: extension
Issues Open issues Closed issues
Code Owners @jpkrohling, @mwear

Overview

This module contains functionality for aggregating status information about components. Used by extensions that implement the componentstatus.Watcher interface for collecting status information about the internal status of all components inside the collector.

History

pkg/status was originally developed for the healthcheckv2extension. It provided a generic way of aggregating status information for components. Other extensions that need to implement the componentstatus.Watcher can now use the same implementation healthcheckv2extension uses.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateStatus

type AggregateStatus struct {
	Event

	ComponentStatusMap map[string]*AggregateStatus
}

AggregateStatus contains a map of child AggregateStatuses and an embedded Event. It can be used to represent a single, top-level status when the ComponentStatusMap is empty, or a nested structure when map is non-empty.

type Aggregator

type Aggregator struct {
	// contains filtered or unexported fields
}

Aggregator records individual status events for components and aggregates statuses for the pipelines they belong to and the collector overall.

func NewAggregator

func NewAggregator(errPriority ErrorPriority) *Aggregator

NewAggregator returns a *status.Aggregator.

func (*Aggregator) AggregateStatus

func (a *Aggregator) AggregateStatus(scope Scope, verbosity Verbosity) (*AggregateStatus, bool)

AggregateStatus returns an *AggregateStatus for the given scope. The scope can be the collector overall (ScopeAll), extensions (ScopeExtensions), or a pipeline by name. Detail specifies whether or not subtrees should be returned with the *AggregateStatus. The boolean return value indicates whether or not the scope was found.

func (*Aggregator) Close

func (a *Aggregator) Close()

Close terminates all existing subscriptions.

func (*Aggregator) RecordStatus

func (a *Aggregator) RecordStatus(source *componentstatus.InstanceID, event *componentstatus.Event)

RecordStatus stores and aggregates a StatusEvent for the given component instance.

func (*Aggregator) Subscribe

func (a *Aggregator) Subscribe(scope Scope, verbosity Verbosity) (<-chan *AggregateStatus, UnsubscribeFunc)

Subscribe allows you to subscribe to a stream of events for the given scope. The scope can be the collector overall (ScopeAll), extensions (ScopeExtensions), or a pipeline name. It is possible to subscribe to a pipeline that has not yet reported. An initial nil will be sent on the channel and events will start streaming if and when it starts reporting. A `Verbose` verbosity specifies that subtrees should be returned with the *AggregateStatus. To unsubscribe, call the returned UnsubscribeFunc.

type ErrorPriority

type ErrorPriority int
const (
	PriorityPermanent ErrorPriority = iota
	PriorityRecoverable
)

type Event

type Event interface {
	Status() componentstatus.Status
	Err() error
	Timestamp() time.Time
}

Note: this interface had to be introduced because we need to be able to rewrite the timestamps of some events during aggregation. The implementation in core doesn't currently allow this, but this interface provides a workaround.

type Scope

type Scope string

Scope refers to a part of an AggregateStatus. The zero-value, aka ScopeAll, refers to the entire AggregateStatus. ScopeExtensions refers to the extensions subtree, and any other value refers to a pipeline subtree.

const (
	ScopeAll        Scope = ""
	ScopeExtensions Scope = "extensions"
)

type UnsubscribeFunc

type UnsubscribeFunc func()

UnsubscribeFunc is a function used to unsubscribe from a stream.

type Verbosity

type Verbosity bool
const (
	Verbose Verbosity = true
	Concise           = false
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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