Documentation
¶
Overview ¶
Package alerts sends native on-failure notifications (#424). The scheduler resolves each dexaflow.yaml alert rule's connection to an endpoint URL and calls a Notifier — Slack incoming webhooks and generic HTTP webhooks — entirely in Go, with no task pod and no Python in the hot path. Connection lookup lives in the caller; this package only renders the message and performs the HTTP POST, so it stays trivially testable and free of storage dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Placeholders = []string{"dag", "run_id", "logical_date", "task", "tasks"}
Placeholders names every substitution Render performs, in the order it documents them. Template validation reads this list, so a placeholder added to value() and here is supported everywhere at once — and one added to only one of them fails the round-trip test rather than silently half-working.
Functions ¶
func Render ¶
Render substitutes the run context into a message template, replacing {{dag}}, {{run_id}}, {{logical_date}}, {{task}} (the first failed task) and {{tasks}} (all failed tasks, comma-separated). An empty template yields a default one-line summary so an operator never receives a blank alert.
Types ¶
type Event ¶
type Event struct {
// DagID is the failed run's DAG id.
DagID string
// RunID is the failed DagRun id.
RunID string
// LogicalDate is the run's logical date (may be empty for unscheduled runs).
LogicalDate string
// FailedTasks lists the task_ids that reached the failed state.
FailedTasks []string
}
Event carries the DagRun context exposed to an alert message template and to the structured webhook payload.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier posts resolved alerts over HTTP. It is safe for concurrent use.
func NewNotifier ¶
NewNotifier returns a Notifier that sends with the given HTTP client. The client SHOULD carry a timeout so a slow endpoint cannot wedge the caller.
func (*Notifier) Send ¶
func (n *Notifier) Send(ctx context.Context, channelType, url string, headers map[string]string, message string, ev Event) error
Send posts message to url for the given channel type: "slack" sends Slack's {"text": …} incoming-webhook shape; "webhook" sends a structured JSON payload carrying the run context. Any headers are applied to the request (e.g. an Authorization header for an endpoint whose token is not in the URL). A non-2xx response or an unknown channel type is an error; the caller decides whether that is fatal (it should not be — an alert failure must not fail the run).