Canaryd.StateMachine (canaryd v0.1.0)

Copy Markdown View Source

Pure transition logic for per-target health. Testable without side effects.

State: %{last_probe, consecutive_failures, last_restart_at, status, updated_at}

Rules (high threshold, restart silently, only bother the user when blocked):

  • probe ok after trouble -> :recovered, reset counters
  • probe fail, restart allowed -> :restart (cooldown: 1h between restarts)
  • probe fail, restart on cooldown, failures < 3 -> :wait (log only)
  • probe fail, restart on cooldown, failures >= 3 -> :blocked (notify once)

Summary

Functions

restart_cooldown_sec()

transition(state, atom, now)