notify

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bark

type Bark struct {
	BaseURL string // e.g. https://api.day.app
	Key     string
	Client  *http.Client
}

Bark posts to a Bark server (iOS push). URL form: <base>/<key>/<title>/<body>.

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