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 ¶
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 ¶
var Catalogue = []Name{ RunFinished, RunFailed, BaselineRecorded, BaselineBlocked, CandidateObserved, CandidateMatured, TransactionStarted, TransactionSucceeded, TransactionRolledBack, TransactionRollbackFailed, BreakerOpened, BreakerCleared, ProposalCreated, ProposalDeployed, ProposalCleared, StackError, StackRecovered, }
Catalogue is every paging-eligible Event name, in catalogue order.
var DefaultPaging = []Name{ RunFailed, TransactionSucceeded, TransactionRolledBack, TransactionRollbackFailed, BreakerOpened, BreakerCleared, ProposalCreated, StackError, StackRecovered, }
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 ¶
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 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 ¶
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) 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.
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.