silence

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package silence provides a storage for silences, which can share its state over a mesh network and snapshot it.

Index

Constants

View Source
const (
	StateActive  SilenceState = "active"
	StatePending              = "pending"
	StateExpired              = "expired"
)

The only possible states of a silence w.r.t a timestamp.

Variables

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

ErrNotFound is returned if a silence was not found.

Functions

This section is empty.

Types

type Options

type Options struct {
	// A snapshot file or reader from which the initial state is loaded.
	// None or only one of them must be set.
	SnapshotFile   string
	SnapshotReader io.Reader

	// Retention time for newly created Silences. Silences may be
	// garbage collected after the given duration after they ended.
	Retention time.Duration

	// A function creating a mesh.Gossip on being called with a mesh.Gossiper.
	Gossip func(g mesh.Gossiper) mesh.Gossip

	// A logger used by background processing.
	Logger  log.Logger
	Metrics prometheus.Registerer
}

Options exposes configuration options for creating a new Silences object. Its zero value is a safe default.

type QueryParam

type QueryParam func(*query) error

QueryParam expresses parameters along which silences are queried.

func QIDs

func QIDs(ids ...string) QueryParam

QIDs configures a query to select the given silence IDs.

func QMatches

func QMatches(set model.LabelSet) QueryParam

QMatches returns silences that match the given label set.

func QState

func QState(states ...SilenceState) QueryParam

QState filters queried silences by the given states.

func QTimeRange

func QTimeRange(start, end time.Time) QueryParam

QTimeRange configures a query to search for silences that are active in the given time range. TODO(fabxc): not supported yet.

type SilenceState

type SilenceState string

SilenceState describes the state of a silence based on its time range.

type Silences

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

Silences holds a silence state that can be modified, queried, and snapshot.

func New

func New(o Options) (*Silences, error)

New returns a new Silences object with the given configuration.

func (*Silences) AddComment

func (s *Silences) AddComment(id string, author, comment string) error

AddComment adds a new comment to the silence with the given ID.

func (*Silences) Create

func (s *Silences) Create(sil *pb.Silence) (id string, err error)

Create adds a new silence and returns its ID.

func (*Silences) Expire

func (s *Silences) Expire(id string) error

Expire the silence with the given ID immediately.

func (*Silences) GC

func (s *Silences) GC() (int, error)

GC runs a garbage collection that removes silences that have ended longer than the configured retention time ago.

func (*Silences) Maintenance

func (s *Silences) Maintenance(interval time.Duration, snapf string, stopc <-chan struct{})

Maintenance garbage collects the silence state at the given interval. If the snapshot file is set, a snapshot is written to it afterwards. Terminates on receiving from stopc.

func (*Silences) Query

func (s *Silences) Query(params ...QueryParam) ([]*pb.Silence, error)

Query for silences based on the given query parameters.

func (*Silences) SetTimeRange

func (s *Silences) SetTimeRange(id string, start, end time.Time) error

SetTimeRange adjust the time range of a silence if allowed. If start or end are zero times, the current value remains unmodified.

func (*Silences) Snapshot

func (s *Silences) Snapshot(w io.Writer) (int, error)

Snapshot writes the full internal state into the writer and returns the number of bytes written.

Directories

Path Synopsis
Package silencepb is a generated protocol buffer package.
Package silencepb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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