Help us shape the future of Go! Take the 2026 Go Developer Survey

failurealert

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package failurealert adapts a DAG's on-failure alert rules (#424) to the scheduler's Alerter seam: it resolves each rule's managed connection to an endpoint URL, renders the message, and sends it via the alerts notifier — best-effort, so a delivery failure is logged and never fails the run. It is the piece that wires the pure notifier (internal/alerts) and the connection store together, kept out of the scheduler so that package stays storage-free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher implements scheduler.Alerter by resolving and sending a run's on-failure alert rules.

func New

func New(notifier sender, resolver EndpointResolver, recorder Recorder, logger *slog.Logger) *Dispatcher

New builds a Dispatcher over the given notifier, connection resolver, metrics recorder (nil disables metrics), and logger.

func (*Dispatcher) AlertRunFailed

func (d *Dispatcher) AlertRunFailed(ctx context.Context, run scheduler.RunState) bool

AlertRunFailed dispatches every on_failure rule of a failed run and reports whether ALL of them were delivered. Each rule is resolved, rendered, and sent independently: a resolver or send error on one rule is logged and skipped so the remaining rules still fire.

The boolean is what lets the caller distinguish a delivered page from a lost one. Before it existed the caller marked the run alerted before sending, so any failure here was permanent (#470 validation: a 500 left the run marked with no retry). All-or-nothing is deliberate: a partial success is retried in full, so a rule that already landed pages twice. That is the trade-off this code already declares — a duplicate beats a missed page.

type Endpoint

type Endpoint struct {
	URL     string
	Headers map[string]string
}

Endpoint is a resolved alert channel: the URL to POST to and any headers the endpoint requires (e.g. an Authorization header when the token is not carried in the URL, as with Opsgenie).

type EndpointResolver

type EndpointResolver interface {
	ResolveAlertEndpoint(ctx context.Context, tenantID, connID string) (Endpoint, error)
}

EndpointResolver maps a managed connection id to its channel Endpoint (including any secret the connection carries). tenantID scopes the lookup. The connection→endpoint contract lives in the implementation so this package needs no storage dependency.

type Recorder

type Recorder interface {
	RecordAlert(dagID, channelType, result string)
}

Recorder counts alert dispatches for observability (principle 10). result is "sent" on a successful POST or "failed" when the connection can't be resolved or the send errors. A nil Recorder disables metrics.

Jump to

Keyboard shortcuts

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