Packages
Dead-man's-switch / heartbeat monitor — flags a job as down when it stops checking in — with its dashboard panel bundled in the same package as a separate module (Integrations.Heartbeat.Display) — one install, both halves; a release without raven_web simply runs the monitor headless.
Current section
Files
Jump to
Current section
Files
lib/integrations/heartbeat/display.ex
defmodule Integrations.Heartbeat.Display do
@moduledoc """
Dashboard panel for `Integrations.Heartbeat` (same package).
Nested under the monitor's own namespace deliberately — the package's
top-level module name never changes, and this module's name is
guaranteed distinct from any separately-published standalone display
package. `Display.BundledDefault` auto-hooks this whenever
`Integrations.Heartbeat` starts, the same as if they were still one module.
"""
use CodeNameRaven.Display, category: :custom, size_hint: :medium
@impl true
def display_name, do: "Heartbeat"
@impl true
def compatible_monitors, do: [Integrations.Heartbeat]
@impl true
def render(assigns) do
result = assigns[:result]
assigns = Map.merge(assigns, %{result: result})
~H"""
<div class="space-y-3">
<div class="flex items-start justify-between gap-2">
<div class="min-w-0">
<h2 class="text-sm font-semibold text-base-content truncate">
<%= @config.name || "Heartbeat" %>
</h2>
</div>
<CodeNameRaven.MonitorComponents.status_chip status={@status} />
</div>
<div :if={@result} class="flex gap-2 flex-wrap">
<CodeNameRaven.MonitorComponents.stat
label="Since last check-in"
value={"#{div(@result.elapsed_ms, 1000)}s"} />
<CodeNameRaven.MonitorComponents.stat
label="Last check-in"
value={if @result.last_checkin_at, do: to_string(@result.last_checkin_at), else: "never"} />
</div>
<CodeNameRaven.MonitorComponents.error_message message={@last_error} />
<CodeNameRaven.MonitorComponents.check_time checked_at={@last_checked_at} />
</div>
"""
end
end