notify

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package notify provides notification support for ralphex plan execution results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	Channels      []string
	OnError       bool
	OnComplete    bool
	TimeoutMs     int
	TelegramToken string
	TelegramChat  string
	SlackToken    string
	SlackChannel  string
	SMTPHost      string
	SMTPPort      int
	SMTPUsername  string
	SMTPPassword  string
	SMTPStartTLS  bool
	EmailFrom     string
	EmailTo       []string
	WebhookURLs   []string
	CustomScript  string
}

Params holds configuration for creating a notification Service. Embedded directly in Config struct — no intermediate mapping needed.

type Result

type Result struct {
	Status    string `json:"status"` // "success" or "failure"
	Mode      string `json:"mode"`
	PlanFile  string `json:"plan_file"`
	Branch    string `json:"branch"`
	Duration  string `json:"duration"`
	Files     int    `json:"files"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Error     string `json:"error,omitempty"`
}

Result holds completion data for notifications.

type Service

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

Service orchestrates sending notifications through configured channels.

func New

func New(p Params, log logger) (*Service, error)

New creates a notification Service from the given Params. returns nil, nil if no channels are configured, enabling callers to skip nil checks via nil-safe Send. validates required fields per channel and returns an error for misconfigured channels.

func (*Service) Send

func (s *Service) Send(ctx context.Context, r Result)

Send sends a notification for the given result. nil-safe on receiver — callers don't need nil checks. checks onError/onComplete flags and sends to all configured channels. errors are logged but never returned (best-effort).

Jump to

Keyboard shortcuts

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