Help us shape the future of Go! Take the 2026 Go Developer Survey

notify

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package notify is keryx's pluggable alert seam (spec 0010 §6): a Notifier interface with config-selected backends (none, webhook, …). `auth refresh` uses it to surface impending-expiry / refresh-failure alerts; a non-zero exit is the always-on baseline regardless of backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discord added in v0.24.0

type Discord struct {
	URL  string
	HTTP *http.Client
}

Discord posts {"content": msg} to a channel's incoming webhook. Discord's webhook payload differs from Slack's ("content", not "text"), which is all that separates this from Webhook.

func (Discord) Notify added in v0.24.0

func (d Discord) Notify(ctx context.Context, msg string) error

Notify posts the message to the webhook.

type Email

type Email struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
	To       []string
	// contains filtered or unexported fields
}

Email sends alerts over SMTP. host/port/from/to come from config; the credentials come from the environment (ALERT_SMTP_USERNAME / ALERT_SMTP_PASSWORD), falling back to config for headless setups.

func (Email) Notify

func (e Email) Notify(ctx context.Context, msg string) error

Notify sends the message as a plain-text email to the configured recipients.

type GitLabIssue added in v0.24.0

type GitLabIssue struct {
	Project string // id or path
	Token   string
	API     string // e.g. https://gitlab.com/api/v4
	HTTP    *http.Client
}

GitLabIssue keeps one open issue per alert title in a project: a first alert opens it, a repeat adds a comment, so a token that keeps expiring is one ticket with a history rather than a ticket a day.

func (GitLabIssue) Notify added in v0.24.0

func (g GitLabIssue) Notify(ctx context.Context, msg string) error

Notify opens or comments on the issue for the message. The title is the message's first clause (up to the first colon after the platform name), so the same platform's alerts collapse onto one issue.

type Multi added in v0.24.0

type Multi []Notifier

Multi delivers to every sink and reports every failure, so one sink being down does not silence the others.

func (Multi) Notify added in v0.24.0

func (m Multi) Notify(ctx context.Context, msg string) error

Notify fans the message out.

type None

type None struct{}

None drops alerts — the caller still exits non-zero (red pipeline). Default.

func (None) Notify

func (None) Notify(context.Context, string) error

Notify is a no-op.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, msg string) error
}

Notifier delivers an alert message to a configured destination.

func New

func New(cfg config.Reader) (Notifier, error)

New builds the configured notifier. auth.alerts.backend names one sink or several, comma-separated: none | webhook | email | discord | gitlab-issue.

type Webhook

type Webhook struct {
	URL  string
	HTTP *http.Client
}

Webhook POSTs {"text": msg} to a Slack/Teams-style incoming webhook.

func (Webhook) Notify

func (w Webhook) Notify(ctx context.Context, msg string) error

Notify posts the message to the webhook URL.

Jump to

Keyboard shortcuts

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