event

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package event is Ripen's Event stream: one stream, many sinks. Every Event goes to the structured stderr sink, always; the webhook Notifier is a second sink that takes a filtered subset and is off by default.

The payload is a single closed struct, not a free map. That is what replaces the Python redaction scrubber: a secret cannot reach an Event because there is no field to put one in, and a test walks the payload's field names to keep it that way.

Index

Constants

View Source
const SchemaVersion = domain.EventSchemaVersion

SchemaVersion is the Event envelope's version. It moves independently of the Response envelope's, and additive changes do not bump it.

Variables

Catalogue is every paging-eligible Event name, in catalogue order.

DefaultPaging is the subset a Notifier delivers when the operator does not name their own: the Events that mean something is wrong, has been fixed, or has changed what is running.

Functions

func Known

func Known(name Name) bool

Known reports whether a name is in the paging catalogue. An unknown name in configuration is a config-load error, never a silent no-op.

Types

type Data

type Data struct {
	Phase          Phase  `json:"phase,omitempty"`
	SkippedStacks  int    `json:"skipped_stacks,omitempty"`
	Mode           string `json:"mode,omitempty"`
	Result         string `json:"result,omitempty"`
	Digest         string `json:"digest,omitempty"`
	OldDigest      string `json:"old_digest,omitempty"`
	NewDigest      string `json:"new_digest,omitempty"`
	Detail         string `json:"detail,omitempty"`
	Reason         string `json:"reason,omitempty"`
	ProposalURL    string `json:"proposal_url,omitempty"`
	Observations   int    `json:"observations,omitempty"`
	UpdatesApplied int    `json:"updates_applied,omitempty"`
	ResultCount    int    `json:"result_count,omitempty"`
	BreakerOpen    bool   `json:"breaker_open,omitempty"`
	Created        bool   `json:"created,omitempty"`
	Attempts       int    `json:"attempts,omitempty"`
	Dropped        int    `json:"dropped,omitempty"`
}

Data is every field any Event payload may carry. One closed struct, deliberately: an Event cannot carry a field nobody reviewed, so no secret can travel in one.

type Envelope

type Envelope struct {
	SchemaVersion int     `json:"schema_version"`
	Event         string  `json:"event"`
	OccurredAt    string  `json:"occurred_at"`
	RunID         *string `json:"run_id"`
	Backend       *string `json:"backend"`
	Stack         *string `json:"stack"`
	Service       *string `json:"service"`
	Actor         string  `json:"actor"`
	Data          Data    `json:"data"`
}

Envelope is one Event on the wire.

type Name

type Name string

Name is an Event's name: noun first, dotted.

const (
	RunFinished Name = "run.finished"
	RunFailed   Name = "run.failed"

	BaselineRecorded Name = "baseline.recorded"
	BaselineBlocked  Name = "baseline.blocked"

	CandidateObserved Name = "candidate.observed"
	CandidateMatured  Name = "candidate.matured"

	TransactionStarted        Name = "transaction.started"
	TransactionSucceeded      Name = "transaction.succeeded"
	TransactionRolledBack     Name = "transaction.rolled_back"
	TransactionRollbackFailed Name = "transaction.rollback_failed"

	BreakerOpened  Name = "breaker.opened"
	BreakerCleared Name = "breaker.cleared"

	ProposalCreated  Name = "proposal.created"
	ProposalDeployed Name = "proposal.deployed"
	ProposalCleared  Name = "proposal.cleared"

	StackError     Name = "stack.error"
	StackRecovered Name = "stack.recovered"
)

The Event catalogue. These seventeen are the paging-eligible Events — every name a `notifier.events` list may contain.

const (
	TransactionProgress    Name = "transaction.progress"
	NotifierTest           Name = "notifier.test"
	NotifierDeliveryFailed Name = "notifier.delivery_failed"
)

Operational Events also exist outside the paging catalogue. NotifierTest is what `ripen notify test` sends, and it bypasses filtering by definition — the point is to prove the real path works. NotifierDeliveryFailed never leaves the stream: a Notifier cannot page about its own inability to page.

type Phase added in v1.2.0

type Phase string

Phase names a persisted Transaction phase.

const (
	PhaseDeploying   Phase = "deploying"
	PhaseVerifying   Phase = "verifying"
	PhaseRollingBack Phase = "rolling_back"
	PhaseProposing   Phase = "proposing"
)

Persisted Transaction phases.

type Sink

type Sink interface {
	Emit(envelope Envelope)
}

Sink receives Events. Sinks must not fail a run: a sink that errors swallows it, and one that panics is contained by the stream.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream fans one Event out to every sink, in order.

func NewStream

func NewStream(actor domain.Actor, sinks ...Sink) *Stream

NewStream builds a stream for one surface. The actor is the surface itself and is stamped on every Event; it is never a parameter a caller can supply.

func (*Stream) Add

func (s *Stream) Add(sink Sink)

Add attaches another sink.

func (*Stream) AddSuccessReport added in v1.3.0

func (s *Stream) AddSuccessReport()

AddSuccessReport attaches the human-readable success report to the structured Event sink's synchronized writer.

func (*Stream) Emit

func (s *Stream) Emit(name Name, subject Subject, data Data)

Emit stamps and fans out one Event.

func (*Stream) WithClock

func (s *Stream) WithClock(clock func() time.Time) *Stream

WithClock replaces the stream's clock, for tests.

type Subject

type Subject struct {
	RunID   string
	Backend domain.Backend
	Stack   string
	Service string
}

Subject is who an Event is about.

type SuccessReportSink added in v1.3.0

type SuccessReportSink struct {
	// contains filtered or unexported fields
}

SuccessReportSink writes a human-readable report for each successful Transaction.

func NewSuccessReportSink added in v1.3.0

func NewSuccessReportSink(writer io.Writer) *SuccessReportSink

NewSuccessReportSink builds a sink for human-readable daemon reports.

func (*SuccessReportSink) Emit added in v1.3.0

func (s *SuccessReportSink) Emit(envelope Envelope)

Emit writes a report only for a successful Transaction.

type WriterSink

type WriterSink struct {
	// contains filtered or unexported fields
}

WriterSink writes every Event as one line of JSON. This is the sink that is always on: on stderr, so stdout stays the Response envelope's alone.

func NewWriterSink

func NewWriterSink(writer io.Writer) *WriterSink

NewWriterSink builds the structured stream sink.

func (*WriterSink) Emit

func (w *WriterSink) Emit(envelope Envelope)

Emit writes one Event.

Jump to

Keyboard shortcuts

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