notification

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 15 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

Index

Constants

View Source
const FileName = "notifications.toml"
View Source
const WebBaseDirRoutePrefix = "/_basedir/"

WebBaseDirRoutePrefix is the Web UI path prefix that serves one basedir as WebBaseDirRoutePrefix + WebBaseDirID(baseDir) + "/".

Variables

This section is empty.

Functions

func AvailableFields

func AvailableFields() []string

AvailableFields returns every field in its default display order.

func FormatValue

func FormatValue(value any) string

func Marshal

func Marshal(settings Settings) ([]byte, error)

func Template

func Template() []byte

func Validate

func Validate(settings Settings) error

func WebBaseDirID added in v0.1.21

func WebBaseDirID(baseDir string) string

WebBaseDirID returns the Web UI route ID of baseDir, an absolute, clean path.

Types

type Batch

type Batch struct {
	SchemaVersion int     `json:"schema_version"`
	CreatedAt     string  `json:"created_at"`
	Project       string  `json:"project"`
	RunID         string  `json:"run_id"`
	RunName       string  `json:"run_name,omitempty"`
	Events        []Event `json:"events"`
	OmittedJobs   int     `json:"omitted_jobs,omitempty"`
}

func NewBatch

func NewBatch(events []Event, settings ChannelSettings, createdAt time.Time) Batch

func (Batch) Empty

func (batch Batch) Empty() bool

type BrowserMessage added in v0.1.24

type BrowserMessage struct {
	Title string `json:"title"`
	Body  string `json:"body"`
	// Link reports whether the message opens its run, which the "link" field
	// selects.
	Link bool `json:"link"`
}

BrowserMessage is one browser notification: an inbox entry and, for a page that sees it arrive, a desktop notification.

func NewBrowserMessage added in v0.1.24

func NewBrowserMessage(events []Event, settings ChannelSettings) (BrowserMessage, bool)

NewBrowserMessage renders one run's events with browser settings. Selected job failures, then job successes, each up to settings.MaxJobs, and the run's completion become sections of "field name: value" lines in settings.Fields order. It reports false when settings select none of the events.

type ChannelSettings

type ChannelSettings struct {
	JobFailure bool     `json:"job_failure"`
	JobSuccess bool     `json:"job_success"`
	RunFailure bool     `json:"run_failure"`
	RunSuccess bool     `json:"run_success"`
	Fields     []string `json:"fields"`
	MaxJobs    int      `json:"max_jobs"`
}

func (ChannelSettings) Includes

func (settings ChannelSettings) Includes(event Event) bool

type Event

type Event struct {
	Kind              EventKind        `json:"event"`
	OccurredAt        string           `json:"occurred_at"`
	Project           string           `json:"project,omitempty"`
	RunID             string           `json:"run_id,omitempty"`
	RunName           string           `json:"run_name,omitempty"`
	RunStatus         string           `json:"run_status,omitempty"`
	JobStatus         string           `json:"job_status,omitempty"`
	ExitCode          int              `json:"exit_code,omitempty"`
	Successes         int              `json:"success_count,omitempty"`
	Failures          int              `json:"failure_count,omitempty"`
	DiagnosisOutdated bool             `json:"diagnosis_outdated,omitempty"`
	Job               *model.JobSpec   `json:"job,omitempty"`
	Result            *model.JobResult `json:"result,omitempty"`
	StartedAt         string           `json:"started_at,omitempty"`
	FinishedAt        string           `json:"finished_at,omitempty"`
}

func NewInterruptedRunEvent added in v0.1.24

func NewInterruptedRunEvent(project string, run model.RunSummary, occurredAt time.Time) Event

NewInterruptedRunEvent reports run, which has its ID and, when they were recorded, its name and start time, as interrupted.

func NewJobEvent

func NewJobEvent(project, runID, runName string, job model.JobSpec, result model.JobResult, occurredAt time.Time) Event

func NewRunEvent

func NewRunEvent(project string, summary model.RunSummary, occurredAt time.Time) Event

func (Event) Recordable added in v0.1.24

func (event Event) Recordable() Event

Recordable returns event with only the job and result facts that the shared field vocabulary reads, so a kept record carries no environment, executor options, or other job settings.

func (*Event) SetDiagnosisOutdated

func (event *Event) SetDiagnosisOutdated(outdated bool)

func (*Event) SetTimestamps

func (event *Event) SetTimestamps(startedAt, finishedAt string)

type EventKind

type EventKind string
const (
	JobFinished EventKind = "job.finished"
	RunFinished EventKind = "run.finished"
	// RunInterrupted is a run whose process stopped before finishing it,
	// found by rotari web; it is recorded for the Web inbox only.
	RunInterrupted EventKind = "run.interrupted"
)

type Field

type Field struct {
	Name  string `json:"name"`
	Value any    `json:"value"`
}

type Loaded

type Loaded struct {
	Settings Settings
	Path     string
}

func Load

func Load(baseDir, projectName string) (Loaded, error)

Load reads the first notifications.toml of the project, the basedir, and the global config directory. With no basedir, as for a Web terminal shell of no project, only the global one.

type Payload

type Payload struct {
	SchemaVersion int            `json:"schema_version"`
	CreatedAt     string         `json:"created_at"`
	Events        []PayloadEvent `json:"events"`
	OmittedJobs   int            `json:"omitted_jobs,omitempty"`
}

func NewPayload

func NewPayload(batch Batch, selected []string, webURL, baseDir string) Payload

NewPayload builds the webhook payload for batch. webURL is the root of the rotari web server; links open the run under baseDir's route because one notifications.toml can serve runs of any basedir.

type PayloadEvent

type PayloadEvent struct {
	Event  EventKind `json:"event"`
	Fields []Field   `json:"fields"`
}

type Settings

type Settings struct {
	Webhook  WebhookSettings  `json:"webhook"`
	Browser  ChannelSettings  `json:"browser"`
	Terminal TerminalSettings `json:"terminal"`
}

func Defaults

func Defaults() Settings

func Parse

func Parse(data []byte) (Settings, error)

type TerminalSettings added in v0.1.30

type TerminalSettings struct {
	CommandFailure bool `json:"command_failure"`
	CommandSuccess bool `json:"command_success"`
	MinSeconds     int  `json:"min_seconds"`
}

TerminalSettings say which commands run in the Web terminal's shells raise a desktop notification when they end out of sight: by how they ended and how long they ran.

func (TerminalSettings) Notifies added in v0.1.30

func (settings TerminalSettings) Notifies(exit *int, took time.Duration) bool

Notifies says whether a command that ended with exit (nil for none) after took is one to notify: a failure is a status other than 0, or none.

type WebhookSettings

type WebhookSettings struct {
	ChannelSettings
	URL    string `json:"url,omitempty"`
	WebURL string `json:"web_url,omitempty"`
	Format string `json:"format"`
}

Jump to

Keyboard shortcuts

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