gatealert

package
v1.0.593 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gatealert is the alert engine of the publication gate's aggregate conditions (ADR-0064 part D5b, "Alerts", R1-L2): when to page, when to recover, and the text.

Contract

  • One page on entering a condition, with the node count; no re-page while it stays present or flaps.
  • Recovery only after the condition has stayed clear for ClearFor; a reappearance restarts that period.
  • A page is latched only when it is deliverable (an enabled webhook subscribes to its event). An undeliverable page is not spent: the condition stays unpaged and the next evaluation tries again. A condition that clears unpaged sends no recovery.
  • Paged now: not ancestry and contradiction, the two conditions that mean something on an unarmed gate. The armed-gate conditions land with arming, on this engine.

Boundary

A leaf: standard library only, no package state, no init, no goroutine, no clock of its own (the time is passed in). The application owns the report table and the freshness window that produce the counts, when evaluations run, which events have subscribers, and dispatch.

Index

Constants

View Source
const (
	EventNotAncestry   = "publication_gate_not_ancestry"
	EventContradiction = "publication_gate_contradiction"
	EventRecovered     = "publication_gate_recovered"
)

Events.

View Source
const ClearFor = 10 * time.Minute

ClearFor is how long a condition must stay clear before its recovery is paged.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Event  string
	Detail string
}

Alert is one page or recovery to dispatch.

type Counts

type Counts struct {
	NotAncestry   int
	Contradiction int
}

Counts are the nodes in each condition, among those the application counts as fresh.

type Engine

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

Engine holds the conditions' alert states. The zero value is ready; it is safe for concurrent use.

func (*Engine) Active

func (e *Engine) Active(event string) bool

Active reports whether event's condition has been paged and not yet recovered (false for an event this engine does not page).

func (*Engine) Evaluate

func (e *Engine) Evaluate(c Counts, now time.Time, subscribed func(event string) bool) []Alert

Evaluate folds counts at now into the alert states and returns the pages and recoveries to dispatch. subscribed reports whether an event's page can reach a subscriber; it runs under the engine's lock, so it must not call back into the engine.

type Hysteresis

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

Hysteresis is one aggregate condition's alert state.

func (*Hysteresis) Active

func (h *Hysteresis) Active() bool

Active reports whether the condition has been paged and not yet recovered.

func (*Hysteresis) Step

func (h *Hysteresis) Step(present, deliverable bool, now time.Time, clearFor time.Duration) (page, recovered bool)

Step folds whether the condition is present at now. It pages on entering the condition when the page is deliverable (otherwise the condition stays unpaged and the next step tries again) and recovers only once it has stayed clear for clearFor.

Jump to

Keyboard shortcuts

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