Help us shape the future of Go! Take the 2026 Go Developer Survey

provider

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 272

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("item not found")

ErrNotFound is returned if a provider cannot find a requested item.

Functions

This section is empty.

Types

type Alert added in v0.30.0

type Alert struct {
	// Header contains metadata, for example propagated tracing information.
	Header map[string]string
	Data   *types.Alert
}

type AlertIterator

type AlertIterator interface {
	Iterator
	// Next returns a channel that will be closed once the iterator is
	// exhausted. It is not necessary to exhaust the iterator but Close must
	// be called in any case to release resources used by the iterator (even
	// if the iterator is exhausted).
	Next() <-chan *Alert
}

AlertIterator is an Iterator for Alerts.

func NewAlertIterator

func NewAlertIterator(ch <-chan *Alert, done chan struct{}, err error) AlertIterator

NewAlertIterator returns a new AlertIterator based on the generic alertIterator type.

type Alerts

type Alerts interface {
	// Subscribe returns an iterator over active alerts that have not been
	// resolved and successfully notified about.
	// They are not guaranteed to be in chronological order.
	Subscribe(name string) AlertIterator

	// SlurpAndSubcribe returns a list of all active alerts which are available
	// in the provider before the call to SlurpAndSubcribe and an iterator
	// of all alerts available after the call to SlurpAndSubcribe.
	// SlurpAndSubcribe can be used by clients which need to build in memory state
	// to know when they've processed the 'initial' batch of alerts in a provider
	// after they reload their subscription.
	// Implementation of SlurpAndSubcribe is optional - providers may choose to
	// return an empty list for the first return value and the result of Subscribe
	// for the second return value.
	SlurpAndSubscribe(name string) ([]*types.Alert, AlertIterator)

	// GetPending returns an iterator over all alerts that have
	// pending notifications.
	GetPending() AlertIterator
	// Get returns the alert for a given fingerprint.
	Get(model.Fingerprint) (*types.Alert, error)
	// Put adds the given set of alerts to the set.
	Put(ctx context.Context, alerts ...*types.Alert) error
}

Alerts gives access to a set of alerts. All methods are goroutine-safe.

type Iterator

type Iterator interface {
	// Err returns the current error. It is not safe to call it concurrently
	// with other iterator methods or while reading from a channel returned
	// by the iterator.
	Err() error
	// Close must be called to release resources once the iterator is not
	// used anymore.
	Close()
}

Iterator provides the functions common to all iterators. To be useful, a specific iterator interface (e.g. AlertIterator) has to be implemented that provides a Next method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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