Arrea.Monitor (Arrea v2.1.0)

Copy Markdown View Source

Global monitor for the Arrea engine.

Responsible for:

  • Registering and updating worker state
  • Notifying worker completion
  • Providing aggregate statistics for workers, tasks, and errors

The Monitor is an internal component that accumulates statistics. External subscribers live on Arrea.Leader; the Monitor no longer maintains a subscriber set of its own.

Summary

Functions

Child specification for the supervision tree.

Returns the current state of the monitor.

Returns summarised Engine statistics.

Registers a worker in the monitor.

Starts the Monitor as a GenServer with name Elixir.Arrea.Monitor.

Updates a worker's state.

Notifies the monitor that a worker has finished.

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: map()

Child specification for the supervision tree.

get_state()

@spec get_state() :: map()

Returns the current state of the monitor.

get_stats()

@spec get_stats() :: {:ok, map()}

Returns summarised Engine statistics.

register_worker(worker_id, state)

@spec register_worker(any(), map()) :: :ok

Registers a worker in the monitor.

start_link(opts \\ [])

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

Starts the Monitor as a GenServer with name Elixir.Arrea.Monitor.

update_worker(worker_id, updates)

@spec update_worker(any(), map()) :: :ok

Updates a worker's state.

worker_finished(worker_id, status, duration_ms)

@spec worker_finished(any(), atom(), integer()) :: :ok

Notifies the monitor that a worker has finished.