notify

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package notify delivers short operational messages (SSH login alerts, audit denials, task failures) to one or more user-configured channels. It is deliberately dependency-free: every channel is a plain HTTPS POST built on the standard library, so the server keeps its zero-dependency footprint.

Index

Constants

View Source
const (
	BarkDefaultLevel = "active"
	BarkDefaultGroup = "lattice"
)

Variables

View Source
var BarkLevels = []string{"active", "timeSensitive", "passive", "critical"}

BarkLevels lists the interruption levels bark-server accepts.

Functions

This section is empty.

Types

type Bark

type Bark struct {
	BaseURL string // e.g. https://api.day.app
	Key     string
	Level   string // Bark interruption level; defaults to BarkDefaultLevel
	Group   string // Bark notification group; defaults to BarkDefaultGroup
	URL     string // optional URL opened when the notification is tapped
	Client  *http.Client
}

Bark pushes to a Bark server (iOS push). It sends the v2 JSON form, POST <base>/push {device_key, title, body, level, group, url}, and falls back to the legacy path form GET <base>/<key>/<title>/<body> when the server answers 404 or 405 (bark-server 1.x has no /push route).

func (Bark) Kind

func (b Bark) Kind() string

func (Bark) Send

func (b Bark) Send(ctx context.Context, m Message) error

type Channel

type Channel interface {
	Kind() string
	Send(ctx context.Context, m Message) error
}

Channel delivers a Message to a single destination.

type Discord

type Discord struct {
	WebhookURL string
	Client     *http.Client
}

Discord posts to an incoming webhook URL.

func (Discord) Kind

func (d Discord) Kind() string

func (Discord) Send

func (d Discord) Send(ctx context.Context, m Message) error

type Dispatcher

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

Dispatcher fans a message out to every configured channel, isolating failures so one broken channel does not suppress the others.

func NewDispatcher

func NewDispatcher(channels ...Channel) *Dispatcher

func (*Dispatcher) Send

func (d *Dispatcher) Send(ctx context.Context, m Message) []Result

Send delivers m to all channels and returns a per-channel result slice. The call itself never errors; inspect the results for per-channel failures.

type Message

type Message struct {
	Title string
	Body  string
}

Message is a channel-agnostic notification.

type Result

type Result struct {
	Kind string
	Err  error
}

Result records the outcome of sending to one channel.

type Telegram

type Telegram struct {
	Token   string
	ChatID  string
	BaseURL string // defaults to https://api.telegram.org
	Client  *http.Client
}

Telegram posts via the Bot API sendMessage method.

func (Telegram) Kind

func (t Telegram) Kind() string

func (Telegram) Send

func (t Telegram) Send(ctx context.Context, m Message) error

type Webhook

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

Webhook posts a generic JSON document {title, body} to an arbitrary URL.

func (Webhook) Kind

func (h Webhook) Kind() string

func (Webhook) Send

func (h Webhook) Send(ctx context.Context, m Message) error

Jump to

Keyboard shortcuts

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