notifyalert

package
v1.175.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 9 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 notifyalert sends the platform's own alerts -- a review queue past its threshold, a connection whose credential was revoked, a scheduled run that failed, a storage or webhook condition -- to the people, personas and notification channels an operator named for each (#1724, #2909).

An alert is authorized as the platform. The operator who named a person, persona or channel in the alert's settings is the authorization: no persona is consulted for the send, and it is charged to no actor. Each channel send passes its own key, so the channel's repeat window applies to an alert that keeps firing. A person is told through the Inbox, and by email as their preference for the alert's category says.

Index

Constants

MaxChannels bounds the channels one alert names, as notification.MaxChannelRecipients bounds an email list.

Variables

View Source
var ErrNoChannelStore = errors.New("this deployment has no notification channels to name")

ErrNoChannelStore is returned by Validate for a channel named on a deployment that stores no channels.

View Source
var ErrUnknownChannel = errors.New("no notification channel has that name")

ErrUnknownChannel is wrapped by Validate for a name no channel is stored under.

View Source
var ErrUnknownPersona = errors.New("no persona has that name")

ErrUnknownPersona is wrapped by ValidateRouting for a name no persona has.

Functions

func Normalize

func Normalize(names []string) []string

Normalize trims a submitted channel list, dropping blanks and repeats, so a form's empty last line or a doubled entry is not stored.

func Validate

func Validate(ctx context.Context, store notification.ChannelStore, names []string) error

Validate refuses a channel list an alert cannot send to: too many entries, or a name no channel is stored under. A channel that exists but is disabled is accepted, as it is everywhere else an operator names one: enabling it later should not mean re-entering it here.

func ValidateRouting added in v1.175.0

func ValidateRouting(ctx context.Context, store notification.ChannelStore, known func(persona string) bool, r notification.Routing) error

ValidateRouting refuses a routing naming a persona known does not report or a channel no channel is stored under. Its bounds and addresses are checked by notification.RoutingInput.Apply. known nil refuses any persona.

Types

type Personas added in v1.175.0

type Personas struct {
	Known   func(name string) bool
	Members func(ctx context.Context, name string) []string
}

Personas is what an alert needs to know of personas: whether one exists, and the people it reaches when the alert is sent (the confirmed people in the user directory whose recorded roles resolve to it). A nil func knows no persona and reaches nobody.

type Reach added in v1.175.0

type Reach struct {
	People   int
	Channels int
}

Reach is how many people and channels an alert was queued for.

type Sender

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

Sender sends an alert to people, personas and channels. A nil Sender sends nothing, which is how a deployment with no database is wired.

func New

func New(channels notification.ChannelStore, enqueuer *notification.Enqueuer, personas Personas) *Sender

New builds a Sender, or nil when there is no enqueuer. With no channel store the alert reaches people only.

func (*Sender) Check added in v1.175.0

func (s *Sender) Check(ctx context.Context, r notification.Routing) error

Check refuses a routing naming a persona or channel that does not exist. A nil Sender refuses any persona or channel.

func (*Sender) People added in v1.175.0

func (s *Sender) People(ctx context.Context, r notification.Routing) []string

People is who r reaches now: its addresses and each member of its personas, deduplicated, in that order. A nil Sender resolves no persona.

func (*Sender) Route added in v1.175.0

Route tells the people r reaches and posts to its channels under key, and reports how many of each it queued for.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, names []string, key string, p notification.Payload) int

Send queues the alert's payload for each named channel under key and returns how many channels it was queued for. A channel that is gone, disabled, over its cap or failing is logged and the rest still go out: one bad entry must not silence the alert for every other channel.

func (*Sender) Tell added in v1.175.0

Tell writes the alert to the Inbox of each person r reaches, emailed by their preference for its kind's category, and returns how many it reached. A kind that names no category is filed under Alerts. The platform raised it, so no actor is named.

Jump to

Keyboard shortcuts

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