pharos/alert_manager

Per-threshold alert state machine.

Wraps an eparch/state_machine running the four-state lifecycle Clear → Pending → Firing → Cooling → Clear. The state machine is registered under a deterministic Name so that supervisor restarts keep AlertManager handles valid: callers send Breach / Recover casts to the registered name, which the OTP runtime resolves to the current pid on each call.

breach/1 and recover/1 map physical signals (threshold crossed up / down) to state transitions. The dispatcher is notified with AlertFiring and AlertResolved events on the relevant transitions.

Types

Restart-resilient handle to a per-threshold alert state machine.

pub opaque type AlertManager

Internal command messages.

pub type Message {
  Breach
  Recover
}

Constructors

  • Breach
  • Recover

Values

pub fn breach(manager: AlertManager) -> Nil

Signal that the threshold has been breached.

pub fn from_name(name: process.Name(Message)) -> AlertManager

Wrap a registered name as an AlertManager. The supervisor uses this to build handles before the underlying state machine has been started, so that the handler-attacher can route breach/recover signals to a stable address.

pub fn recover(manager: AlertManager) -> Nil

Signal that the threshold is no longer breached.

pub fn start_link(
  data: alert.AlertData,
  bus: event_bus.EventBus,
  name: process.Name(Message),
) -> Result(AlertManager, state_machine.StartError)

Start a state machine for data, registering it under name. Notifies bus with AlertFiring / AlertResolved events on the relevant transitions.

Search Document