CouncilEx.Runner.RecorderProcess (CouncilEx v0.1.0)

Copy Markdown View Source

GenServer that hosts a CouncilEx.Recorder callback module for a single run.

Started by CouncilEx.start/3 before the RunServer (so the subscribe to the run topic lands in time for :run_started). Spawned unsupervised (GenServer.start/3 semantics). Subscribes to the run topic in init/1, dispatches each broadcast event to the user's handle_event/2, and calls handle_finalize/2 exactly once on terminal outcome — either via the :run_completed / :run_failed PubSub events, or via Process.monitor/1 if the RunServer dies without broadcasting.

Internal — do not use directly. Configure via the :recorder option on CouncilEx.start/3.

Summary

Functions

Returns a specification to start this module under a supervisor.

Inform the recorder of the RunServer pid so it can monitor for crashes that don't produce a terminal broadcast.

Unsupervised + unlinked spawn (mirrors GenServer.start/3).

Start a recorder process for run_id with the given user module and args.

Types

t()

@type t() :: %CouncilEx.Runner.RecorderProcess{
  finalized: boolean(),
  module: module(),
  run_id: String.t(),
  run_monitor: reference() | nil,
  run_pid: pid() | nil,
  user_state: term()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

set_run_pid(recorder_pid, run_pid)

@spec set_run_pid(pid(), pid()) :: :ok

Inform the recorder of the RunServer pid so it can monitor for crashes that don't produce a terminal broadcast.

Sent from CouncilEx.start/3 after DynamicSupervisor.start_child/2 succeeds.

start(opts)

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

Unsupervised + unlinked spawn (mirrors GenServer.start/3).

start_link(opts)

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

Start a recorder process for run_id with the given user module and args.

This call subscribes to the run topic synchronously and invokes module.init(run_id, args) before returning, guaranteeing no events are missed between recorder start and RunServer start.