Help us shape the future of Go! Take the 2026 Go Developer Survey

events

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package events is the catalog of things Pando tells subscribers about (R-364, issue #50, design 11).

One list, in code, of every event a subscription can name: its stable name, whether it is about one app or the whole installation, where it comes from, and the fields it carries. The API serves it, `make reference` writes docs/events.md from it, and the console's subscription form offers it, so none of those can describe an event the others do not.

This package is a leaf: it imports nothing from core, so the state package, the audit writer and the delivery engine can all depend on it.

Index

Constants

View Source
const (
	AppStateChanged     = "app.state_changed"
	DeploySucceeded     = "deploy.succeeded"
	DeployFailed        = "deploy.failed"
	BackupCreated       = "backup.created"
	BackupFailed        = "backup.failed"
	AdapterUnhealthy    = "adapter.unhealthy"
	AdapterRecovered    = "adapter.recovered"
	SubscriptionTest    = "subscription.test"
	SubscriptionDisable = "subscription.disabled"
)

Event names core writes directly, and the ones a trigger writes, as constants so a typo is a compile error rather than an event nobody can subscribe to.

Variables

This section is empty.

Functions

func Match

func Match(pattern, name string) bool

Match reports whether pattern matches the event name.

func MatchAny

func MatchAny(patterns []string, name string) bool

MatchAny reports whether any pattern matches.

func ValidPattern

func ValidPattern(p string) bool

ValidPattern reports whether p names an event or matches at least one.

A pattern is an event name, a prefix ending in ".*" (deploy.*), or "*". A pattern that matches nothing is refused rather than stored: a subscription to "deploy.fialed" would be a subscription that never fires, which is the worst way to find out about a typo.

Types

type Def

type Def struct {
	Name    string  `json:"name"`
	Scope   Scope   `json:"scope"`
	Source  Source  `json:"source"`
	Summary string  `json:"summary"`
	Fields  []Field `json:"fields"`

	// Actions are the audit actions this event is copied from, when Source
	// is SourceAudit.
	Actions []string `json:"-"`
}

Def is one catalogued event.

func Catalog

func Catalog() []Def

Catalog returns every event, in documentation order. The slice is a copy.

func ForAction

func ForAction(action string) (Def, bool)

ForAction returns the event an audit action is copied to, if any.

func Lookup

func Lookup(name string) (Def, bool)

Lookup returns one event by name.

func (Def) Data

func (d Def) Data(detail map[string]any) map[string]any

Data selects an event's fields from an audit event's detail.

Only catalogued fields are copied, so an event's shape is what the catalog says it is, and a field somebody later adds to an audit detail does not reach a subscriber's endpoint without first being written down here.

type Field

type Field struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Field is one entry in an event's data.

type Scope

type Scope string

Scope is what an event is about.

const (
	// ScopeApp events name one app, and reach subscriptions on that app as
	// well as install-wide ones.
	ScopeApp Scope = "app"
	// ScopeInstall events are about the installation, and reach install-wide
	// subscriptions only.
	ScopeInstall Scope = "install"
)

type Source

type Source string

Source is where Pando learns an event happened.

const (
	// SourceAudit: copied from the audit log as the audit row is written, in
	// the same transaction.
	SourceAudit Source = "audit"
	// SourceState: written by a database trigger when a row changes.
	SourceState Source = "state"
	// SourceCore: written by core directly.
	SourceCore Source = "core"
)

Jump to

Keyboard shortcuts

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