alert

package
v0.62.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package alert tells the operator that a source could not be synced or reloaded: an error line in the log, and a JSON POST to a webhook when one is configured.

Webhook body

One JSON object: {"text":"arnakoff: AMF update failed: <error>", "source":"AMF","at":"<RFC 3339>","error":"<error>"}. text reads on its own in a chat channel; the other fields are for a machine. The error names the source and why, never a personal datum: connectors quote no value of the files they parse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

Notifier logs each alert and posts it to a webhook. It implements app.Alerter and is safe for concurrent use.

func ForWebhook

func ForWebhook(logger *slog.Logger, webhook string) (*Notifier, error)

ForWebhook returns a Notifier logging to logger and posting to webhook, an HTTPS URL, through an HTTP client allowed to reach its host only. Its errors never quote webhook.

func LogOnly

func LogOnly(logger *slog.Logger) *Notifier

LogOnly returns a Notifier that only logs to logger.

func New

func New(logger *slog.Logger, poster Poster, webhook string) *Notifier

New returns a Notifier logging to logger and posting through poster to webhook.

func (*Notifier) Alert

func (n *Notifier) Alert(ctx context.Context, a app.Alert)

Alert logs a and posts it to the webhook, if any. A webhook failure is logged, without the URL.

type Poster

type Poster interface {
	Post(ctx context.Context, rawURL, contentType string, body []byte) error
}

Poster sends a body to a URL; *httpclient.Client is one. Its errors must not quote the URL.

Jump to

Keyboard shortcuts

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