Documentation
¶
Index ¶
- Constants
- type DiscordNotificationProvider
- type EmailNotificationProvider
- type GenericWebhookProvider
- type LeveledProvider
- type NotificationSettings
- func (ns NotificationSettings) SendDiscord(ctx context.Context, title, message string, wf storage.Workflow) error
- func (ns NotificationSettings) SendEmail(ctx context.Context, title, message string, wf storage.Workflow) error
- func (ns NotificationSettings) SendGenericWebhook(ctx context.Context, title, message string, wf storage.Workflow) error
- func (ns NotificationSettings) SendSlack(ctx context.Context, title, message string, wf storage.Workflow) error
- func (ns NotificationSettings) SendTelegram(ctx context.Context, title, message string, wf storage.Workflow) error
- func (ns NotificationSettings) Test(ctx context.Context) []TestResult
- type Provider
- type Service
- func (s *Service) AddProvider(p Provider)
- func (s *Service) Notify(ctx context.Context, title, message string, wf storage.Workflow)
- func (s *Service) NotifyLevel(ctx context.Context, level, title, message string, wf storage.Workflow)
- func (s *Service) SetLogger(l hermod.Logger)
- func (s *Service) SetStorage(s2 storage.Storage)
- func (s *Service) Wait()
- func (s *Service) WaitFor(d time.Duration) bool
- type SlackNotificationProvider
- type TelegramNotificationProvider
- type TestResult
- type UINotificationProvider
- func (p *UINotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error
- func (p *UINotificationProvider) SendLeveled(ctx context.Context, level, title, message string, wf storage.Workflow) error
- func (p *UINotificationProvider) SetStorage(s storage.Storage)
- func (p *UINotificationProvider) Type() string
Constants ¶
const ( LevelInfo = "INFO" LevelWarn = "WARN" LevelError = "ERROR" )
Severity levels for an alert. They exist because not every notification is a fault: a workflow an operator stopped, or a worker draining during a deploy, is routine. UINotificationProvider wrote every alert at ERROR, so adding lifecycle notifications would have filed routine events as errors in the log table and in the UI's error view.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscordNotificationProvider ¶
type DiscordNotificationProvider struct {
// contains filtered or unexported fields
}
func NewDiscordNotificationProvider ¶
func NewDiscordNotificationProvider(s storage.Storage) *DiscordNotificationProvider
func (*DiscordNotificationProvider) SetStorage ¶
func (p *DiscordNotificationProvider) SetStorage(s storage.Storage)
func (*DiscordNotificationProvider) Type ¶
func (p *DiscordNotificationProvider) Type() string
type EmailNotificationProvider ¶
type EmailNotificationProvider struct {
// contains filtered or unexported fields
}
func NewEmailNotificationProvider ¶
func NewEmailNotificationProvider(s storage.Storage) *EmailNotificationProvider
func (*EmailNotificationProvider) SetStorage ¶
func (p *EmailNotificationProvider) SetStorage(s storage.Storage)
func (*EmailNotificationProvider) Type ¶
func (p *EmailNotificationProvider) Type() string
type GenericWebhookProvider ¶
type GenericWebhookProvider struct {
// contains filtered or unexported fields
}
func NewGenericWebhookProvider ¶
func NewGenericWebhookProvider(s storage.Storage) *GenericWebhookProvider
func (*GenericWebhookProvider) SetStorage ¶
func (p *GenericWebhookProvider) SetStorage(s storage.Storage)
func (*GenericWebhookProvider) Type ¶
func (p *GenericWebhookProvider) Type() string
type LeveledProvider ¶ added in v1.11.0
type LeveledProvider interface {
SendLeveled(ctx context.Context, level, title, message string, wf storage.Workflow) error
}
LeveledProvider is the optional interface for a provider that records a severity. Providers that push to a human (Telegram, Slack, email) do not need one — the title carries the meaning there — so the interface stays optional rather than widening Provider for a single implementation.
type NotificationSettings ¶
type NotificationSettings struct {
SMTPHost string `json:"smtp_host"`
SMTPPort int `json:"smtp_port"`
SMTPUser string `json:"smtp_user"`
SMTPPassword string `json:"smtp_password"`
SMTPFrom string `json:"smtp_from"`
SMTPSSL bool `json:"smtp_ssl"`
DefaultEmail string `json:"default_email"`
TelegramToken string `json:"telegram_token"`
TelegramChatID string `json:"telegram_chat_id"`
SlackWebhook string `json:"slack_webhook"`
DiscordWebhook string `json:"discord_webhook"`
WebhookURL string `json:"webhook_url"`
BaseURL string `json:"base_url"`
}
func (NotificationSettings) SendDiscord ¶
func (NotificationSettings) SendGenericWebhook ¶
func (NotificationSettings) SendTelegram ¶
func (NotificationSettings) Test ¶
func (ns NotificationSettings) Test(ctx context.Context) []TestResult
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AddProvider ¶
func (*Service) Notify ¶
Notify raises an alert at ERROR. Most alerts are faults; the ones that are not go through NotifyLevel.
func (*Service) NotifyLevel ¶ added in v1.11.0
func (s *Service) NotifyLevel(ctx context.Context, level, title, message string, wf storage.Workflow)
NotifyLevel raises an alert at an explicit severity.
func (*Service) SetLogger ¶ added in v1.11.0
SetLogger routes provider failures to the process log.
They went to fmt.Printf, so a rejected Telegram token or a webhook returning 500 appeared on stdout and nowhere else: not in the structured log, not in the log table, not in the UI. The one thing an operator needs to know about an alerting channel is that it has stopped working.
func (*Service) SetStorage ¶
func (*Service) Wait ¶ added in v1.11.0
func (s *Service) Wait()
Wait blocks until every dispatched notification has finished. It exists for shutdown and for tests; the send path itself never waits.
func (*Service) WaitFor ¶ added in v1.11.0
WaitFor blocks until in-flight notifications finish or d elapses, and reports whether they finished.
Shutdown needs this. The fan-out runs on its own goroutine, so the alert saying a worker is going down was raced by the process exiting — dispatched, never sent. Waiting without a bound is the opposite mistake: an unreachable channel would hold the shutdown open for the full send timeout.
type SlackNotificationProvider ¶
type SlackNotificationProvider struct {
// contains filtered or unexported fields
}
func NewSlackNotificationProvider ¶
func NewSlackNotificationProvider(s storage.Storage) *SlackNotificationProvider
func (*SlackNotificationProvider) SetStorage ¶
func (p *SlackNotificationProvider) SetStorage(s storage.Storage)
func (*SlackNotificationProvider) Type ¶
func (p *SlackNotificationProvider) Type() string
type TelegramNotificationProvider ¶
type TelegramNotificationProvider struct {
// contains filtered or unexported fields
}
func NewTelegramNotificationProvider ¶
func NewTelegramNotificationProvider(s storage.Storage) *TelegramNotificationProvider
func (*TelegramNotificationProvider) SetStorage ¶
func (p *TelegramNotificationProvider) SetStorage(s storage.Storage)
func (*TelegramNotificationProvider) Type ¶
func (p *TelegramNotificationProvider) Type() string
type TestResult ¶
type UINotificationProvider ¶
type UINotificationProvider struct {
// contains filtered or unexported fields
}
func NewUINotificationProvider ¶
func NewUINotificationProvider(s storage.Storage) *UINotificationProvider
func (*UINotificationProvider) SendLeveled ¶ added in v1.11.0
func (p *UINotificationProvider) SendLeveled(ctx context.Context, level, title, message string, wf storage.Workflow) error
SendLeveled records the alert in the log table at the severity it was raised with, so a routine stop does not read as a failure.
func (*UINotificationProvider) SetStorage ¶
func (p *UINotificationProvider) SetStorage(s storage.Storage)
func (*UINotificationProvider) Type ¶
func (p *UINotificationProvider) Type() string