notify

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package notify carries reconcile events to whoever is listening.

This seam is additive where the others replace, and the asymmetry is deliberate. A Business Edition notifier posting to Slack must not remove the log notifier — and, the case that actually forces it, the HTTP API's event stream is itself a notifier. If registering replaced, loading the companion would silently kill the UI's live updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active() []string

Active names every registered notifier, for startup logging.

func Dispatch

func Dispatch(ctx context.Context, e Event)

Dispatch delivers e to every registered notifier.

func Register

func Register(name string, n Notifier)

Register appends a notifier. It removes nothing. Call it from an init().

Types

type Event

type Event struct {
	Application string
	Type        EventType
	Revision    string // the resolved commit, where one applies
	Message     string
	At          time.Time
	// Swarm is the destination the event concerns, as
	// application.Spec.Destination names it. Empty is the swarm the controller
	// runs in.
	//
	// It is here because routing is what a Business Edition notifier does —
	// production alerts to one channel, staging to another — and without it the
	// only thing to route on is Message, which is prose written for a human.
	// Deciding where an alert goes by matching on a sentence is a notifier that
	// breaks when somebody improves the wording.
	//
	// Empty is the ordinary value in an Apache-2.0 build and means the swarm the
	// controller runs in, because that is the only destination swarms.Registry's
	// OSS default resolves (D2) and the only one an application can name without
	// a companion loaded. It is not "unknown": the reconciler stamps every event
	// it raises with the application's own destination, whatever that is (#131).
	Swarm string
}

Event is one thing that happened to one application.

type EventType

type EventType string

EventType names what happened.

const (
	SyncStarted   EventType = "sync-started"
	SyncSucceeded EventType = "sync-succeeded"
	SyncFailed    EventType = "sync-failed"
	// DriftDetected reports that the repository moved: a commit changed what
	// the application declares and the swarm has not caught up.
	DriftDetected EventType = "drift-detected"
	// LiveDriftDetected reports that the *swarm* moved: the running services of
	// a release the repository has not touched no longer match it, which under
	// driftDetection: live is the only way an out-of-band change is ever seen.
	//
	// Deliberately not DriftDetected with a different message. The two need
	// different responses — one is a commit to review, the other is a change
	// nobody recorded — and a notifier that routes on the type must be able to
	// tell them apart without parsing prose.
	LiveDriftDetected EventType = "live-drift-detected"
	// DriftConverged reports that the controller corrected one. Message names
	// the releases it redeployed.
	//
	// It exists because the correction is otherwise invisible: no chart
	// revision is written for it — the desired state did not change — so
	// without this the only trace of a service being rewritten under an
	// operator is a status field that has already gone back to none.
	DriftConverged EventType = "drift-converged"
	// ResourcesPruned reports that the controller deleted the deployed
	// resources of something git no longer declares — a whole application that
	// left the app set, a release an application stopped declaring, or a
	// service, network, config or secret its chart stopped declaring. Message
	// names what went.
	//
	// It is the loudest thing this controller does, and the only event that
	// reports something destroyed rather than converged.
	ResourcesPruned EventType = "resources-pruned"
	// PruneFailed reports that the deletion did not complete. What it names is
	// still deployed and still unmanaged; the next reconcile tries again.
	PruneFailed EventType = "prune-failed"
)

type Notifier

type Notifier interface {
	Notify(ctx context.Context, e Event)
}

Notifier receives events.

Notify returns nothing and must not block. A notification that cannot be delivered is not a reason to fail a sync, so implementations report their own delivery failures; an error return would only make every caller write the same log-and-continue.

func All

func All() []Notifier

All returns every registered notifier.

Jump to

Keyboard shortcuts

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