notifier

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotificationStatusFromRestoreStatus

func NotificationStatusFromRestoreStatus(status string) ports.BackupStatus

NotificationStatusFromRestoreStatus maps restore execution status values to notifier event categories used by channel event filters.

func SanitizeForSlack

func SanitizeForSlack(text string) string

SanitizeForSlack removes characters that may break Slack formatting

func ShouldNotify

func ShouldNotify(events []string, status ports.BackupStatus) bool

ShouldNotify checks if notification should be sent for given status.

func StatusEmoji

func StatusEmoji(status ports.BackupStatus) string

StatusEmoji returns an emoji based on backup status

Types

type DiscordNotifier

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

DiscordNotifier sends notifications to Discord via webhook

func NewDiscordNotifier

func NewDiscordNotifier(config *ports.WebhookNotificationConfig) *DiscordNotifier

NewDiscordNotifier creates a new Discord notifier

func (*DiscordNotifier) IsEnabled

func (d *DiscordNotifier) IsEnabled() bool

IsEnabled returns whether the notifier is enabled

func (*DiscordNotifier) Send

func (d *DiscordNotifier) Send(ctx context.Context, backup *ports.BackupContext) error

Send is deprecated, use SendBackup instead

func (*DiscordNotifier) SendBackup

func (d *DiscordNotifier) SendBackup(ctx context.Context, backup *ports.BackupContext) error

SendBackup sends a backup notification to Discord

func (*DiscordNotifier) SendRestore

func (d *DiscordNotifier) SendRestore(ctx context.Context, restore *ports.RestoreContext) error

SendRestore sends a restore notification to Discord

func (*DiscordNotifier) Type

func (d *DiscordNotifier) Type() string

Type returns the notifier type

type Dispatcher

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

Dispatcher handles sending notifications to multiple channels

func NewDispatcher

func NewDispatcher(logger *slog.Logger) *Dispatcher

NewDispatcher creates a new notification dispatcher

func NewDispatcherFromConfig

func NewDispatcherFromConfig(notifications []config.NotificationChannel) (*Dispatcher, error)

NewDispatcherFromConfig creates a dispatcher and adds notifiers from config.

func NewDispatcherFromRestoreConfig

func NewDispatcherFromRestoreConfig(notifications []config.NotificationChannel) (*Dispatcher, error)

NewDispatcherFromRestoreConfig creates a dispatcher for restore notifications. It uses the same notification channels as backups.

func (*Dispatcher) AddEmailNotifier

func (d *Dispatcher) AddEmailNotifier(config *ports.EmailNotificationConfig) error

AddEmailNotifier adds an email notifier

func (*Dispatcher) AddWebhookNotifier

func (d *Dispatcher) AddWebhookNotifier(config *ports.WebhookNotificationConfig) error

AddWebhookNotifier adds a webhook-based notifier (Slack, Discord, or generic webhook)

func (*Dispatcher) Clear

func (d *Dispatcher) Clear()

Clear removes all registered notifiers

func (*Dispatcher) Count

func (d *Dispatcher) Count() int

Count returns the number of registered notifiers

func (*Dispatcher) Notify

func (d *Dispatcher) Notify(backup *ports.BackupContext) error

Notify sends notifications synchronously to all configured channels Collects and returns all errors (non-blocking - continues sending even if one fails)

func (*Dispatcher) NotifyAsync

func (d *Dispatcher) NotifyAsync(backup *ports.BackupContext) <-chan error

NotifyAsync sends notifications asynchronously to all configured channels Returns a channel that closes when all notifications are sent

func (*Dispatcher) NotifyRestore

func (d *Dispatcher) NotifyRestore(restore *ports.RestoreContext) error

NotifyRestore sends notifications synchronously for restore operations

func (*Dispatcher) NotifyRestoreAsync

func (d *Dispatcher) NotifyRestoreAsync(restore *ports.RestoreContext) <-chan error

NotifyRestoreAsync sends notifications asynchronously for restore operations

func (*Dispatcher) SetTimeout

func (d *Dispatcher) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for notification delivery

type EmailNotifier

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

EmailNotifier sends notifications via SMTP email

func NewEmailNotifier

func NewEmailNotifier(config *ports.EmailNotificationConfig) *EmailNotifier

NewEmailNotifier creates a new email notifier

func (*EmailNotifier) IsEnabled

func (e *EmailNotifier) IsEnabled() bool

IsEnabled returns whether the notifier is enabled

func (*EmailNotifier) Send

func (e *EmailNotifier) Send(ctx context.Context, backup *ports.BackupContext) error

Send is deprecated, use SendBackup instead

func (*EmailNotifier) SendBackup

func (e *EmailNotifier) SendBackup(ctx context.Context, backup *ports.BackupContext) error

SendBackup sends a backup notification via email

func (*EmailNotifier) SendRestore

func (e *EmailNotifier) SendRestore(ctx context.Context, restore *ports.RestoreContext) error

SendRestore sends a restore notification via email

func (*EmailNotifier) Type

func (e *EmailNotifier) Type() string

Type returns the notifier type

type FormattedMessage

type FormattedMessage struct {
	Title       string
	MessageText string
	Details     map[string]string
	Status      ports.BackupStatus
	Timestamp   time.Time
}

FormattedMessage contains the formatted notification message

func FormatMessage

func FormatMessage(backup *ports.BackupContext) *FormattedMessage

FormatMessage formats a backup context into a notification message

func FormatRestoreMessage

func FormatRestoreMessage(restore *ports.RestoreContext) *FormattedMessage

FormatRestoreMessage formats a restore context into a notification message

type SlackNotifier

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

SlackNotifier sends notifications to Slack via webhook

func NewSlackNotifier

func NewSlackNotifier(config *ports.WebhookNotificationConfig) *SlackNotifier

NewSlackNotifier creates a new Slack notifier

func (*SlackNotifier) IsEnabled

func (s *SlackNotifier) IsEnabled() bool

IsEnabled returns whether the notifier is enabled

func (*SlackNotifier) Send

func (s *SlackNotifier) Send(ctx context.Context, backup *ports.BackupContext) error

Send is deprecated, use SendBackup instead

func (*SlackNotifier) SendBackup

func (s *SlackNotifier) SendBackup(ctx context.Context, backup *ports.BackupContext) error

SendBackup sends a backup notification to Slack

func (*SlackNotifier) SendRestore

func (s *SlackNotifier) SendRestore(ctx context.Context, restore *ports.RestoreContext) error

SendRestore sends a restore notification to Slack

func (*SlackNotifier) Type

func (s *SlackNotifier) Type() string

Type returns the notifier type

type StatusColor

type StatusColor struct {
	// SlackHex is the hex color code for Slack messages (e.g., "#36a64f")
	SlackHex string
	// DiscordInt is the integer color code for Discord embeds (e.g., 3066993)
	DiscordInt int
	// Name is the human-readable status name
	Name string
}

StatusColor defines color representations for notification statuses across different platforms.

Internal to the notifier adapter — not part of the dispatcher/notifier port contract. Channel-specific rendering helpers live alongside the concrete channel implementations.

func GetStatusColor

func GetStatusColor(status ports.BackupStatus) StatusColor

GetStatusColor returns the color configuration for a given backup status. This ensures consistent colors across all notification platforms.

type WebhookNotifier

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

WebhookNotifier sends notifications to a generic webhook endpoint

func NewWebhookNotifier

func NewWebhookNotifier(config *ports.WebhookNotificationConfig) *WebhookNotifier

NewWebhookNotifier creates a new generic webhook notifier

func (*WebhookNotifier) IsEnabled

func (w *WebhookNotifier) IsEnabled() bool

IsEnabled returns whether the notifier is enabled

func (*WebhookNotifier) Send

func (w *WebhookNotifier) Send(ctx context.Context, backup *ports.BackupContext) error

Send is deprecated, use SendBackup instead

func (*WebhookNotifier) SendBackup

func (w *WebhookNotifier) SendBackup(ctx context.Context, backup *ports.BackupContext) error

SendBackup sends a backup notification to the webhook endpoint

func (*WebhookNotifier) SendRestore

func (w *WebhookNotifier) SendRestore(ctx context.Context, restore *ports.RestoreContext) error

SendRestore sends a restore notification to the webhook endpoint

func (*WebhookNotifier) Type

func (w *WebhookNotifier) Type() string

Type returns the notifier type

Jump to

Keyboard shortcuts

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