alertsender

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = func(name Type) error { return fmt.Errorf("invalid config for %q sender", name) }

ErrInvalidConfig signals an invalid sender config

Functions

func LoadAll

func LoadAll(configs []Config) error

LoadAll loads all alert senders from the configuration inputs.

func Register

func Register(typ Type, factory Factory)

Register registers a new alert sender.

Types

type Alert

type Alert struct {
	// Title is the short title that summarizes the purpose of the alert.
	Title string
	// Text is the longer textual content that further explains what this alert is about.
	Text string
	// Tags contains a sequence of tags for categorizing the alerts.
	Tags []string
	// Severity determines the severity of this alert.
	Severity Severity
}

Alert encapsulates the state of an alert.

func NewAlert

func NewAlert(title, text string, tags []string, severity Severity) Alert

NewAlert builds a new alert.

func (*Alert) MDToHTML added in v1.8.0

func (a *Alert) MDToHTML() error

MDToHTML converts alert's text Markdown elements to HTML blocks.

func (Alert) String

func (a Alert) String() string

String returns the alert string representation.

type Config

type Config struct {
	Type   Type
	Sender interface{}
}

Config is the container for the alert sender configuration structure.

type Factory

type Factory func(config Config) (Sender, error)

Factory defines the alias for the alert sender factory

type Sender

type Sender interface {
	// Send emits an alert.
	Send(Alert) error
	// Type returns the type that identifies a particular sender.
	Type() Type
}

Sender is the minimal interface all alert senders have to implement.

func Find

func Find(typ Type) Sender

Find locates the sender.

func FindAll

func FindAll() []Sender

FindAll returns all registered senders.

func Load

func Load(config Config) (Sender, error)

Load loads an alert sender from the registry.

type Severity

type Severity uint8

Severity is the type alias for alert's severity level.

const (
	// Normal designates alert's normal level
	Normal Severity = iota
	// Medium designates alert's medium level
	Medium
	// Critical designates alert's critical level
	Critical
)

func ParseSeverityFromString

func ParseSeverityFromString(sever string) Severity

ParseSeverityFromString parses the severity from the string representation.

func (Severity) String

func (s Severity) String() string

String returns severity human-friendly name.

type Type

type Type uint8

Type defines the alias for the alert sender type

const (
	// Mail designates mail alert sender
	Mail Type = iota
	// Slack designates Slack alert sender
	Slack
	// Noop is a noop alert sender. Useful for testing.
	Noop
	// None is the type for unknown alert sender
	None
)

func ToType

func ToType(s string) Type

ToType converts the string representation of the alert sender to its corresponding type.

func (Type) String

func (s Type) String() string

String returns the string representation of the alert sender type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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