Raxol.Swarm.NodeMonitor (Raxol v2.3.0)

View Source

Health and latency tracking for cluster nodes.

Monitors nodes via :net_kernel.monitor_nodes/1, pings at a configurable interval, and maintains RTT history per node. Notifies subscribers on status changes (healthy -> suspect -> down).

Summary

Types

health_record()

@type health_record() :: %{
  node: node(),
  rtt_history: [float()],
  avg_rtt_ms: float(),
  last_seen: integer(),
  status: status(),
  joined_at: integer()
}

status()

@type status() :: :healthy | :suspect | :down

t()

@type t() :: %Raxol.Swarm.NodeMonitor{
  nodes: %{required(node()) => health_record()},
  ping_interval_ms: pos_integer(),
  ping_ref: reference() | nil,
  subscribers: [pid()]
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_health(server \\ __MODULE__, node)

@spec get_health(GenServer.server(), node()) ::
  {:ok, health_record()} | {:error, :unknown}

list_all(server \\ __MODULE__)

@spec list_all(GenServer.server()) :: [health_record()]

list_healthy(server \\ __MODULE__)

@spec list_healthy(GenServer.server()) :: [node()]

list_suspect(server \\ __MODULE__)

@spec list_suspect(GenServer.server()) :: [node()]

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

subscribe(server \\ __MODULE__)

@spec subscribe(GenServer.server()) :: :ok

unsubscribe(server \\ __MODULE__)

@spec unsubscribe(GenServer.server()) :: :ok