notify

package
v0.3.0-rc.53 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 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

Overview

Package notify sends through the channels that are not the Feishu app: Pushover (iOS emergency alerts that repeat until acknowledged), Bark (an iOS push that rings), the Feishu group's custom bot (plain messages that need no app and spend no API quota), signed team webhooks, and healthchecks.io pings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ping

func Ping(ctx context.Context, hc *http.Client, checkURL string, ok bool) error

Ping reports to a healthchecks.io check: success, or failure (the /fail endpoint).

func Sign

func Sign(timestamp, secret string) string

Sign is the custom bot's signature: base64(HMAC-SHA256 with key "timestamp\nsecret" over nothing).

func SignWebhook

func SignWebhook(secret string, body []byte) string

SignWebhook returns the Beacon signature of the exact bytes sent to a webhook.

func SlackMessage

func SlackMessage(heading, incidentURL, openLabel string) []byte

SlackMessage renders a plain-text incident title with an optional, generated link. Only the link section uses Slack markup, and it contains no text from the alert itself.

func ValidSlackWebhookURL

func ValidSlackWebhookURL(raw string) bool

ValidSlackWebhookURL accepts the official Slack and GovSlack incoming webhook endpoints.

func ValidWebhookURL

func ValidWebhookURL(raw string) bool

ValidWebhookURL reports whether an endpoint is an absolute HTTP(S) URL without userinfo or a fragment.

Types

type Bark

type Bark struct {
	URL  string // https://api.day.app/<key>
	HTTP *http.Client
}

Bark sends an iOS push through a Bark server; critical pushes ring through silent mode.

func (*Bark) Send

func (b *Bark) Send(ctx context.Context, title, body, link string) error

Send sends a critical, ringing push.

type Emergency

type Emergency struct {
	Title, Message, URL, URLTitle string
}

Emergency is an emergency-priority message.

type GroupBot

type GroupBot struct {
	URL     string
	Secret  string
	Keyword string
	HTTP    *http.Client
	// contains filtered or unexported fields
}

GroupBot posts plain text to a Feishu group through its custom bot. The bot's security setting is a keyword (every message must contain it) and optionally a signing secret.

func (*GroupBot) Send

func (g *GroupBot) Send(ctx context.Context, text string) error

Send posts text, adding the keyword when the text lacks it. The text mentions nobody: what it quotes (an alert's title, a command run on a machine) comes from outside Beacon.

type Pushover

type Pushover struct {
	API     string // https://api.pushover.net
	Token   string // application token
	User    string // user key
	Retry   time.Duration
	Expire  time.Duration
	HTTP    *http.Client
	Enabled bool
}

Pushover sends emergency-priority messages to one user.

func (*Pushover) Cancel

func (p *Pushover) Cancel(ctx context.Context, receipt string) error

Cancel stops retries for a single emergency message identified by its receipt.

func (*Pushover) Receipt

func (p *Pushover) Receipt(ctx context.Context, receipt string) (Receipt, error)

Receipt looks up an emergency message's receipt.

func (*Pushover) Send

func (p *Pushover) Send(ctx context.Context, m Emergency) (string, error)

Send sends an emergency (priority 2) message and returns its receipt.

type Receipt

type Receipt struct {
	Acknowledged bool
	At           time.Time
	Device       string
	Expired      bool
}

Receipt is the state of an emergency message.

type Slack

type Slack struct {
	URL string
	// contains filtered or unexported fields
}

Slack delivers incident messages to a Slack app's incoming webhook.

func (*Slack) Send

func (s *Slack) Send(ctx context.Context, body []byte) error

Send submits the exact queued message to Slack. A response without Slack's acceptance marker can be a proxy page and must not be counted as an accepted alert.

type SlackRateLimited

type SlackRateLimited struct{ After time.Duration }

SlackRateLimited is the retry interval from a Slack rate-limit response.

func (SlackRateLimited) Error

func (SlackRateLimited) Error() string

type Webhook

type Webhook struct {
	URL    string
	Secret string
}

Webhook delivers signed team notifications to a fixed HTTP(S) endpoint.

func (Webhook) Send

func (w Webhook) Send(ctx context.Context, body []byte) error

Send posts a raw JSON notification body. The receiver's HTTP status determines delivery success.

Jump to

Keyboard shortcuts

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