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.
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.
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>".
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>".