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 ¶
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 ¶
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.