Snakepit.HeartbeatMonitor (Snakepit v0.6.10)

View Source

Monitors a worker process using a configurable heartbeat protocol.

The monitor periodically invokes a ping function and expects the worker to send a pong via notify_pong/2. Missed heartbeats trigger worker termination, allowing supervisors to restart the worker.

Summary

Functions

Returns a specification to start this module under a supervisor.

Retrieve current monitor status.

Notify the monitor that a pong response has been received.

Types

start_option()

@type start_option() ::
  {:worker_pid, pid()}
  | {:worker_id, String.t()}
  | {:ping_interval_ms, non_neg_integer()}
  | {:timeout_ms, non_neg_integer()}
  | {:max_missed_heartbeats, non_neg_integer()}
  | {:ping_fun, (integer() -> :ok | {:ok, term()} | {:error, term()} | term())}
  | {:dependent, boolean()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_status(monitor_pid)

@spec get_status(pid()) :: map()

Retrieve current monitor status.

notify_pong(monitor_pid, timestamp)

@spec notify_pong(pid(), integer()) :: :ok

Notify the monitor that a pong response has been received.

start_link(opts)

@spec start_link([start_option()]) :: GenServer.on_start()