Documentation
¶
Index ¶
- Constants
- func AvailableFields() []string
- func FormatValue(value any) string
- func Marshal(settings Settings) ([]byte, error)
- func Template() []byte
- func UnresponsiveExplanation(event Event) string
- func Validate(settings Settings) error
- func WebBaseDirID(baseDir string) string
- type Batch
- type BrowserMessage
- type ChannelSettings
- type Event
- func NewInterruptedRunEvent(project string, run model.RunSummary, occurredAt time.Time) Event
- func NewJobEvent(project, runID, runName string, job model.JobSpec, result model.JobResult, ...) Event
- func NewRunEvent(project string, summary model.RunSummary, occurredAt time.Time) Event
- func NewUnresponsiveRunEvent(project string, run model.RunSummary, host, lastBeatAt string, ...) Event
- type EventKind
- type Field
- type Loaded
- type Payload
- type PayloadEvent
- type Settings
- type TerminalSettings
- type WebhookSettings
Constants ¶
const FileName = "notifications.toml"
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 UnresponsiveExplanation ¶ added in v0.1.31
UnresponsiveExplanation says what a run.unresponsive event saw: which host stopped writing the heartbeat and for how long, and that the run may still be running, so it must be checked before it is unlocked.
func WebBaseDirID ¶ added in v0.1.21
WebBaseDirID returns the Web UI route ID of baseDir, an absolute, clean path.
Types ¶
type Batch ¶
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"`
// Host and LastHeartbeatAt are where an unresponsive run's coordinator
// ran and the time its last heartbeat recorded, by that host's clock.
Host string `json:"host,omitempty"`
LastHeartbeatAt string `json:"last_heartbeat_at,omitempty"`
// SilentSeconds is how long the heartbeat had not changed when the run
// was found unresponsive, by the clock of the process that found it.
SilentSeconds int64 `json:"silent_seconds,omitempty"`
}
func NewInterruptedRunEvent ¶ added in v0.1.24
NewInterruptedRunEvent reports run, which has its ID and, when they were recorded, its name and start time, as interrupted.
func NewJobEvent ¶
func NewRunEvent ¶
func NewUnresponsiveRunEvent ¶ added in v0.1.31
func NewUnresponsiveRunEvent(project string, run model.RunSummary, host, lastBeatAt string, silent time.Duration, occurredAt time.Time) Event
NewUnresponsiveRunEvent reports run, which has its ID and, when they were recorded, its name and start time, as unresponsive: its coordinator on host last wrote a heartbeat at lastBeatAt, by its own clock, and the beat had not changed for silent.
func (Event) Recordable ¶ added in v0.1.24
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) SetTimestamps ¶
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" // RunUnresponsive is an active run whose coordinator, on another host or // in another PID namespace, has stopped writing its heartbeat. Nothing // proves that it stopped; it is recorded for the Web inbox only. RunUnresponsive EventKind = "run.unresponsive" )
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"`
}
type PayloadEvent ¶
type Settings ¶
type Settings struct {
Webhook WebhookSettings `json:"webhook"`
Browser ChannelSettings `json:"browser"`
Terminal TerminalSettings `json:"terminal"`
}
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.
type WebhookSettings ¶
type WebhookSettings struct {
ChannelSettings
URL string `json:"url,omitempty"`
WebURL string `json:"web_url,omitempty"`
Format string `json:"format"`
}