notification

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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) Send

func (p *DiscordNotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

func (*DiscordNotificationProvider) SetStorage

func (p *DiscordNotificationProvider) SetStorage(s storage.Storage)

func (*DiscordNotificationProvider) Type

type EmailNotificationProvider

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

func NewEmailNotificationProvider

func NewEmailNotificationProvider(s storage.Storage) *EmailNotificationProvider

func (*EmailNotificationProvider) Send

func (p *EmailNotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

func (*EmailNotificationProvider) SetStorage

func (p *EmailNotificationProvider) SetStorage(s storage.Storage)

func (*EmailNotificationProvider) Type

type GenericWebhookProvider

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

func NewGenericWebhookProvider

func NewGenericWebhookProvider(s storage.Storage) *GenericWebhookProvider

func (*GenericWebhookProvider) Send

func (p *GenericWebhookProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

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 (ns NotificationSettings) SendDiscord(ctx context.Context, title, message string, wf storage.Workflow) error

func (NotificationSettings) SendEmail

func (ns NotificationSettings) SendEmail(ctx context.Context, title, message string, wf storage.Workflow) error

func (NotificationSettings) SendGenericWebhook

func (ns NotificationSettings) SendGenericWebhook(ctx context.Context, title, message string, wf storage.Workflow) error

func (NotificationSettings) SendSlack

func (ns NotificationSettings) SendSlack(ctx context.Context, title, message string, wf storage.Workflow) error

func (NotificationSettings) SendTelegram

func (ns NotificationSettings) SendTelegram(ctx context.Context, title, message string, wf storage.Workflow) error

func (NotificationSettings) Test

type Provider

type Provider interface {
	Send(ctx context.Context, title, message string, wf storage.Workflow) error
	Type() string
	SetStorage(s storage.Storage)
}

type Service

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

func NewService

func NewService(s storage.Storage) *Service

func (*Service) AddProvider

func (s *Service) AddProvider(p Provider)

func (*Service) Notify

func (s *Service) Notify(ctx context.Context, title, message string, wf storage.Workflow)

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

func (s *Service) SetLogger(l hermod.Logger)

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 (s *Service) SetStorage(s2 storage.Storage)

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

func (s *Service) WaitFor(d time.Duration) bool

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) Send

func (p *SlackNotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

func (*SlackNotificationProvider) SetStorage

func (p *SlackNotificationProvider) SetStorage(s storage.Storage)

func (*SlackNotificationProvider) Type

type TelegramNotificationProvider

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

func NewTelegramNotificationProvider

func NewTelegramNotificationProvider(s storage.Storage) *TelegramNotificationProvider

func (*TelegramNotificationProvider) Send

func (p *TelegramNotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

func (*TelegramNotificationProvider) SetStorage

func (p *TelegramNotificationProvider) SetStorage(s storage.Storage)

func (*TelegramNotificationProvider) Type

type TestResult

type TestResult struct {
	Channel string `json:"channel"`
	Status  string `json:"status"` // ok | skipped | error
	Error   string `json:"error,omitempty"`
}

type UINotificationProvider

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

func NewUINotificationProvider

func NewUINotificationProvider(s storage.Storage) *UINotificationProvider

func (*UINotificationProvider) Send

func (p *UINotificationProvider) Send(ctx context.Context, title, message string, wf storage.Workflow) error

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

Jump to

Keyboard shortcuts

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