alerter

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package alerter defines the Alerter interface to send alerts whenever a check fails or succeed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, fn newFunc)

Register adds a new alerter to the package. This does not throw an error, rather panics if the alerter with the same name is already registered, hence an alerter should be registered inside the init method of the package.

Types

type Alert

type Alert interface {
	GetService() string // Name of the alert service.

	GetTarget() string // Target of alert.
}

Alert is anything that tells the alerter where to send the alert.

type AlertFunc

type AlertFunc = func(context.Context, []checker.Metric, map[string]Alert) error

AlertFunc is the function that is used to alert the metrics into the provider.

func Initialize

func Initialize(ctx *appcontext.Context, provider Provider) (AlertFunc, error)

Initialize method initializes the alerter and returns a function that alerts the metrics.

type Alerter

type Alerter interface {
	// Provision sets the alerter's configuration.
	Provision(*appcontext.Context, Provider) error

	// Alert actually sends the alert.
	//
	// It gets the metrics for which the alert needs to be sent (all metrics
	// are filtered before passing onto here). The last parameter it has is
	// a map of check IDs and corresponding alert to be sent.
	Alert(context.Context, []checker.Metric, map[string]Alert) error
}

Alerter is responsible for sending alerts.

type Provider

type Provider interface {
	GetService() string // Name of the alert service.

	GetHost() string
	GetPort() uint16
	GetUser() string   // Username or Email.
	GetSecret() string // Password or token.
}

Provider is anything that can be used to configure and create an alerter.

Directories

Path Synopsis
Package discord implements the slack alerter.
Package discord implements the slack alerter.
Package mail implements the mail alerter.
Package mail implements the mail alerter.
Package slack implements the slack alerter.
Package slack implements the slack alerter.

Jump to

Keyboard shortcuts

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