notifier

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SlackUsername variable.
	SlackUsername = "Dewy"
	// SlackIconURL variable.
	SlackIconURL = "https://raw.githubusercontent.com/linyows/dewy/main/misc/dewy-icon.512.png"
	// SlackFooterIcon variable.
	SlackFooterIcon = "https://raw.githubusercontent.com/linyows/dewy/main/misc/dewy-icon.32.png"
)

Functions

This section is empty.

Types

type AttachmentSender added in v0.20.0

type AttachmentSender interface {
	SendHookResult(ctx context.Context, hookType string, result *HookResult)
}

AttachmentSender interface for sending messages with attachments.

type ErrorLimitingSender

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

ErrorLimitingSender wraps a Sender implementation with error limiting functionality.

func (*ErrorLimitingSender) ResetErrorCount

func (e *ErrorLimitingSender) ResetErrorCount()

ResetErrorCount resets error count when operation succeeds.

func (*ErrorLimitingSender) Send

func (e *ErrorLimitingSender) Send(ctx context.Context, message string)

Send sends a message only if error count is 0.

func (*ErrorLimitingSender) SendError

func (e *ErrorLimitingSender) SendError(ctx context.Context, err error)

SendError handles error notifications with count limiting.

func (*ErrorLimitingSender) SendHookResult added in v0.20.0

func (e *ErrorLimitingSender) SendHookResult(ctx context.Context, hookType string, result *HookResult)

SendHookResult sends hook result notification.

type HookResult added in v0.20.0

type HookResult struct {
	Command  string
	Stdout   string
	Stderr   string
	ExitCode int
	Duration time.Duration
	Success  bool
}

HookResult represents the result of executing a deploy hook.

type Mail

type Mail struct {
	Host     string `schema:"host"`
	Port     int    `schema:"port"`
	Username string `schema:"username"`
	Password string `schema:"password"`
	From     string `schema:"from"`
	To       string `schema:"to"`
	Subject  string `schema:"subject"`
	TLS      bool   `schema:"tls"`
	// contains filtered or unexported fields
}

Mail struct.

func NewMail

func NewMail(schema string, logger *slog.Logger) (*Mail, error)

NewMail creates a new Mail notifier.

func (*Mail) Send

func (m *Mail) Send(ctx context.Context, message string)

Send sends an email notification.

func (*Mail) SendHookResult added in v0.20.0

func (m *Mail) SendHookResult(ctx context.Context, hookType string, result *HookResult)

SendHookResult sends hook result via email.

func (*Mail) SetDialer

func (m *Mail) SetDialer(dialer MailDialer)

SetDialer sets the mail dialer for testing purposes.

type MailDialer

type MailDialer interface {
	DialAndSend(m ...*mail.Message) error
}

MailDialer interface for dependency injection and testing.

type Notifier

type Notifier interface {
	Sender
	AttachmentSender
	SendError(ctx context.Context, err error)
	ResetErrorCount()
}

Notifier interface extends Sender with error handling and hook result notifications.

func New

func New(ctx context.Context, url string, logger *slog.Logger) (Notifier, error)

New returns Notifier.

type Null

type Null struct {
}

func (*Null) Send

func (n *Null) Send(ctx context.Context, message string)

func (*Null) SendHookResult added in v0.20.0

func (n *Null) SendHookResult(ctx context.Context, hookType string, result *HookResult)

type Sender

type Sender interface {
	Send(ctx context.Context, message string)
}

Sender interface for basic message sending.

type Slack

type Slack struct {
	Channel  string `schema:"-"`
	Title    string `schema:"title"`
	TitleURL string `schema:"url"`
	// contains filtered or unexported fields
}

Slack struct.

func NewSlack

func NewSlack(schema string, logger *slog.Logger) (*Slack, error)

func (*Slack) BuildAttachment

func (s *Slack) BuildAttachment(message string) objects.Attachment

BuildAttachment returns attachment for slack.

func (*Slack) BuildHookAttachment added in v0.20.0

func (s *Slack) BuildHookAttachment(hookType string, result *HookResult) objects.Attachment

BuildHookAttachment returns attachment for hook result.

func (*Slack) Send

func (s *Slack) Send(ctx context.Context, message string)

Send posts message to Slack channel.

func (*Slack) SendHookResult added in v0.20.0

func (s *Slack) SendHookResult(ctx context.Context, hookType string, result *HookResult)

SendHookResult sends hook result with detailed attachment.

func (*Slack) SetSender

func (s *Slack) SetSender(sender SlackSender)

SetSender sets the slack sender for testing purposes.

type SlackSender

type SlackSender interface {
	SendMessage(ctx context.Context, channel, username, iconURL, text string, attachment *objects.Attachment) error
}

SlackSender interface for dependency injection and testing.

Jump to

Keyboard shortcuts

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