alerter

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package alerter delivers health-check alerts to notification channels.

Every channel implements Alerter. CompositeAlerter fans one alert out to several of them and joins their failures, CompanyFilter restricts a channel to the targets of particular companies, and TelegramAlerter and MattermostAlerter are the shipped implementations. Payloads are encoded with encoding/json/v2 (see json.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerter

type Alerter interface {
	// Send sends an alert notification.
	Send(ctx context.Context, alert domain.Alert) error

	// Name returns the alerter implementation name for logging.
	Name() string
}

Alerter defines the interface for sending alerts.

type CompanyFilter

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

CompanyFilter wraps an Alerter and only forwards alerts whose target company matches one of the configured companies. An empty list is treated as a catch-all.

func NewCompanyFilter

func NewCompanyFilter(inner Alerter, companies []string) *CompanyFilter

NewCompanyFilter wraps inner with a company allow-list.

func (*CompanyFilter) Name

func (f *CompanyFilter) Name() string

Name returns the wrapped alerter's name.

func (*CompanyFilter) Send

func (f *CompanyFilter) Send(ctx context.Context, alert domain.Alert) error

Send forwards the alert to the wrapped alerter when the company matches.

type CompositeAlerter

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

CompositeAlerter fans out alerts to multiple alerters.

func NewCompositeAlerter

func NewCompositeAlerter(alerters ...Alerter) *CompositeAlerter

NewCompositeAlerter creates a composite alerter from multiple alerters.

func (*CompositeAlerter) Add

func (c *CompositeAlerter) Add(alerter Alerter)

Add adds an alerter to the composite.

func (*CompositeAlerter) Name

func (c *CompositeAlerter) Name() string

Name returns the composite alerter name.

func (*CompositeAlerter) Send

func (c *CompositeAlerter) Send(ctx context.Context, alert domain.Alert) error

Send sends an alert to all configured alerters and aggregates errors.

type MattermostAlerter

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

MattermostAlerter sends alerts via a Mattermost incoming webhook.

func NewMattermostAlerter

func NewMattermostAlerter(name, webhookURL, channel, username, iconURL string, timeout time.Duration) *MattermostAlerter

NewMattermostAlerter creates a new Mattermost alerter instance. The channel/username/iconURL arguments override the webhook defaults and may be empty.

func (*MattermostAlerter) Name

func (m *MattermostAlerter) Name() string

Name returns the alerter name in the form "mattermost:<instance>".

func (*MattermostAlerter) Send

func (m *MattermostAlerter) Send(ctx context.Context, alert domain.Alert) error

Send sends an alert via Mattermost.

type TelegramAlerter

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

TelegramAlerter sends alerts via Telegram Bot API.

func NewTelegramAlerter

func NewTelegramAlerter(name, botToken, chatID string, timeout time.Duration) *TelegramAlerter

NewTelegramAlerter creates a new Telegram alerter instance. The name is an operator-chosen label used in logs and error messages.

func (*TelegramAlerter) Name

func (t *TelegramAlerter) Name() string

Name returns the alerter name in the form "telegram:<instance>".

func (*TelegramAlerter) Send

func (t *TelegramAlerter) Send(ctx context.Context, alert domain.Alert) error

Send sends an alert via Telegram.

Jump to

Keyboard shortcuts

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