notify

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 13 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 notifications to offline push channels: an ntfy topic and/or a generic webhook. Sending is asynchronous through a small bounded queue; nothing here ever carries terminal output (callers only pass wire.NotificationData, whose body is a fixed phrase).

Index

Constants

View Source
const Timeout = 5 * time.Second

Timeout bounds one HTTP request.

Variables

This section is empty.

Functions

func Enabled

func Enabled(cfg wire.NotifyConfig) bool

Enabled reports whether cfg has any channel to send to.

func Fold

Fold combines notifications into one. A single notification is returned unchanged; several become reason "digest" with Count set, level warn if any was a warning.

func Push

Push sends n to every enabled channel of cfg synchronously.

Types

type Digester

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

Digester folds the notifications arriving within one window into a single push: the first notification opens a window, and when it closes the collected notifications are flushed as one (unchanged if it was alone, otherwise a "digest" with Count).

func NewDigester

func NewDigester(flush func(wire.NotificationData)) *Digester

NewDigester calls flush for every closed window, from a timer goroutine.

func (*Digester) Add

func (d *Digester) Add(n wire.NotificationData, window time.Duration)

Add queues n into the current window, opening one of the given length if none is open.

func (*Digester) Flush

func (d *Digester) Flush()

Flush closes the current window now (shutdown).

type Sender

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

Sender delivers notifications to the enabled channels of a config.

func NewSender

func NewSender(logf func(format string, args ...any)) *Sender

NewSender returns a Sender. logf (may be nil) receives delivery errors.

func (*Sender) Close

func (s *Sender) Close()

Close stops the worker after the queued pushes (each bounded by Timeout).

func (*Sender) Push

Push sends n to cfg's enabled channels synchronously with the sender's HTTP client (notify.test reports its outcome).

func (*Sender) Send

Send queues n for delivery to cfg's enabled channels without blocking. It reports false when the queue is full (the push is dropped) or the sender is closed.

Jump to

Keyboard shortcuts

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