provider

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned if a provider cannot find a requested item.
	ErrNotFound = fmt.Errorf("item not found")
)

Functions

This section is empty.

Types

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 *types.Alert
}

AlertIterator is an Iterator for Alerts.

func NewAlertIterator

func NewAlertIterator(ch <-chan *types.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() 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 alert to the set.
	Put(...*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.

type MemAlerts

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

MemAlerts implements an Alerts provider based on in-memory data.

func NewMemAlerts

func NewMemAlerts(data *MemData) *MemAlerts

NewMemAlerts returns a new MemAlerts based on the provided data.

func (*MemAlerts) Get

func (a *MemAlerts) Get(fp model.Fingerprint) (*types.Alert, error)

Get implements the Alerts interface.

func (*MemAlerts) GetPending

func (a *MemAlerts) GetPending() AlertIterator

GetPending implements the Alerts interface.

func (*MemAlerts) Put

func (a *MemAlerts) Put(alerts ...*types.Alert) error

Put implements the Alerts interface.

func (*MemAlerts) Subscribe

func (a *MemAlerts) Subscribe() AlertIterator

Subscribe implements the Alerts interface.

type MemData

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

MemData contains the data backing MemAlerts and MemNotifies.

func NewMemData

func NewMemData() *MemData

NewMemData contains an empty but initialized MemData instance.

type MemNotifies

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

MemNotifies implements a Notifies provider based on in-memory data.

func NewMemNotifies

func NewMemNotifies(data *MemData) *MemNotifies

NewMemNotifies returns a new MemNotifies based on the provided data.

func (*MemNotifies) Get

func (n *MemNotifies) Get(dest string, fps ...model.Fingerprint) ([]*types.NotifyInfo, error)

Get implements the Notifies interface.

func (*MemNotifies) Set

func (n *MemNotifies) Set(ns ...*types.NotifyInfo) error

Set implements the Notifies interface.

type MemSilences

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

MemSilences implements a Silences provider based on in-memory data.

func NewMemSilences

func NewMemSilences() *MemSilences

NewMemSilences returns a new MemSilences.

func (*MemSilences) All

func (s *MemSilences) All() ([]*types.Silence, error)

All implements the Silences interface.

func (*MemSilences) Del

func (s *MemSilences) Del(id uint64) error

Del implements the Silences interface.

func (*MemSilences) Get

func (s *MemSilences) Get(id uint64) (*types.Silence, error)

Get implements the Silences interface.

func (*MemSilences) Mutes

func (s *MemSilences) Mutes(lset model.LabelSet) bool

Mutes implements the Muter interface.

func (*MemSilences) Set

func (s *MemSilences) Set(sil *types.Silence) (uint64, error)

Set impelements the Silences interface.

type Notifies

type Notifies interface {
	Get(dest string, fps ...model.Fingerprint) ([]*types.NotifyInfo, error)
	// Set several notifies at once. All or none must succeed.
	Set(ns ...*types.NotifyInfo) error
}

Notifies provides information about pending and successful notifications. All methods are goroutine-safe.

type Silences

type Silences interface {
	// The Silences provider must implement the Muter interface
	// for all its silences. The data provider may have access to an
	// optimized view of the data to perform this evaluation.
	types.Muter

	// All returns all existing silences.
	All() ([]*types.Silence, error)
	// Set a new silence.
	Set(*types.Silence) (uint64, error)
	// Del removes a silence.
	Del(uint64) error
	// Get a silence associated with a fingerprint.
	Get(uint64) (*types.Silence, error)
}

Silences gives access to silences. All methods are goroutine-safe.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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