notify

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package notify warns when a run fails.

It exists because it was the biggest gap against Kestra: the 51 flows in that repository each carried the SAME copied `errors: alert_slack` block -- twenty lines of payload repeated fifty times. Here the alert is a property of the INSTALLATION: configure the webhook once and every workflow starts warning, with the option to silence one.

The webhook does not come from the workflow's YAML, on purpose. It is a credential: whoever has the URL posts in the channel as if they were the platform, and a pipeline file is no place for that.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerta

type Alerta struct {
	Workflow    string
	RunID       string
	Status      string
	Trigger     string
	Tentativas  int
	LogicalDate *time.Time
	Erro        string

	// Passo is the node that failed. It arrives as a field of its own, and not
	// only embedded in the error text, because it is the first thing whoever is
	// on call looks for: "which step?" before "why?".
	Passo string

	// TrechoDoLog is the last few lines of that step's output, read from
	// `task_runs.log`. Without it the alert says something failed; with it the
	// alert says what failed and why, without anyone opening the screen at
	// 4am.
	TrechoDoLog string

	// The workflow's tags become the message's "Domain" and "Pipeline" fields --
	// in Kestra that came from `labels`, and it is what makes an alert
	// actionable without opening the screen.
	Tags []string

	// URLBase of the UI, for the run's direct link. Empty means no link.
	URLBase string
}

Alerta is what gets told about a failure.

type Notificador

type Notificador interface {
	Falhou(ctx context.Context, a Alerta) error
}

Notificador sends the alert. A small interface so the dispatcher knows nothing of Slack -- and so the test needs no network.

type Slack

type Slack struct {
	Webhook string
	Cliente *http.Client

	// Ambiente appears in the header ("prod", "dev"). Without it, a staging
	// alert at three in the morning is indistinguishable from a production
	// one.
	Ambiente string
}

Slack posts to an Incoming Webhook.

func NovoSlack

func NovoSlack(webhook, ambiente string) *Slack

func (*Slack) Falhou

func (s *Slack) Falhou(ctx context.Context, a Alerta) error

Falhou posts the message.

Jump to

Keyboard shortcuts

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