notify

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 10 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 POSTs short messages to Slack and Discord webhooks.

Port of orchestrator/notifications.py. Two properties are load-bearing and both come straight from that file's own reasoning:

  • **Best effort, always.** A broken webhook must never surface into the dispatch loop. The goal is "the operator does not have to babysit the dashboard", not "add another way for a run to die". Every method except Test swallows its errors.
  • **Disabled is the default.** An empty URL disables that channel, and a Notifier with no channels is a working no-op — safe to build and call unconditionally from the engine, which is exactly how the engine uses it.

The event log remains the source of truth for what happened; these are a side channel.

Index

Constants

View Source
const DefaultTimeout = 5 * time.Second

DefaultTimeout is Python's `notifications.timeout_s` default.

Variables

This section is empty.

Functions

func BudgetAlertText

func BudgetAlertText(a budget.Alert) string

BudgetAlertText is the message BudgetAlert sends, exported so `orch notify test --budget` can preview it without a run.

func DigestText

func DigestText(summaryText string, milestones []Milestone) string

DigestText composes the digest body. Pure: no I/O and no clock, so it can be pinned against what Python produced for the same input.

summaryText is `executive_summary`'s own text, reused verbatim rather than rebuilt — that function is the single source of wording for the dashboard and for this, and two phrasings of the same number is worse than one.

The shape, which is what testdata/digest-*.txt pin:

<summary text>

Milestones:
  - Billing: 3/5 — ETA 2026-09-19

with the whole thing trimmed and exactly one trailing newline — so an empty summary and no milestones produce a lone "\n", not an empty string.

Types

type Milestone

type Milestone struct {
	Name  string
	ID    string
	Done  int
	Total int
	// ETADate is a date string, or empty when none has been computed.
	ETADate string
}

Milestone is one row of the digest's table: a name, its progress, and an ETA if one has been computed.

A struct rather than the loose dict Python passes around, so the three fallbacks it applies — name or id or "?", a missing progress counting as 0/0, a missing ETA rendering as an em dash — are visible here rather than spread across `.get()` calls.

type Notifier

type Notifier struct {
	SlackWebhook   string
	DiscordWebhook string
	Timeout        time.Duration

	// Client is the HTTP client. Nil uses a client with Timeout.
	Client *http.Client
	// Log receives the best-effort failures. Nil uses slog's default.
	Log *slog.Logger
}

Notifier posts to whichever channels are configured.

The zero value is a valid disabled notifier, so a caller that never configured one does not need a nil check.

func New

func New(slackWebhook, discordWebhook string, timeoutSeconds float64) *Notifier

New builds a Notifier from the three config values.

func (*Notifier) Blocked

func (n *Notifier) Blocked(ctx context.Context, taskID, reason string)

Blocked announces a task the dispatch loop gave up on.

Only the reason's first line is sent, truncated — see reasonMaxChars. An empty reason becomes "unknown", because a message that just says a task is blocked tells the reader nothing they can act on.

func (*Notifier) BudgetAlert

func (n *Notifier) BudgetAlert(ctx context.Context, a budget.Alert)

BudgetAlert announces a provider whose budget window is near its cap, or has reached it and is deferring tasks. The engine decides when; this only words it.

func (*Notifier) CIBlocked

func (n *Notifier) CIBlocked(ctx context.Context, taskID, prURL string, attempts int)

CIBlocked announces a task blocked because CI kept failing.

func (*Notifier) Enabled

func (n *Notifier) Enabled() bool

Enabled reports whether at least one channel is configured.

func (*Notifier) RunSummary

func (n *Notifier) RunSummary(ctx context.Context, text string)

RunSummary posts a finished run's summary (receipt.Summary's text), all of it: what was built, why each blocked task stopped and what to do next.

func (*Notifier) Stalled

func (n *Notifier) Stalled(ctx context.Context, stalledFor time.Duration, waitingOn string)

Stalled announces a run that has made no progress for stalledFor, and what it is waiting on, cut like a block reason. Go only: Python never noticed a stall (#255).

func (*Notifier) Test

func (n *Notifier) Test(ctx context.Context, message string) bool

Test sends a one-off message and reports whether any channel accepted it.

The one method that answers rather than swallowing: `orch notify test` exists so an operator finds out their webhook is wrong before a run depends on it, which needs a real exit code.

Jump to

Keyboard shortcuts

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