ArchAstro.Channels.ApiTasks (archastro v0.2.0)

Copy Markdown

Phoenix channel for live task-record updates.

Clients join api:tasks:thread:{thread_id} to receive the thread's current event-sourced tasks and subscribe to changes. The join reply carries a full snapshot (%{tasks: [...]}), and every subsequent change lands as a tasks_updated push carrying a fresh snapshot — the same replace-wholesale contract expected by task-panel clients, so clients need no delta bookkeeping.

Change signals originate from ArchAstro.Tasks.Projectors.TaskProjector, which broadcasts on "tasks:thread:{thread_id}" after each committed projection. Bursts (e.g. a mirror reconcile dispatching several commands) are coalesced: the first signal arms a short timer and the reload happens once, after the burst settles.

Summary

Functions

join_thread(socket, thread_id)

@spec join_thread(GenServer.server(), String.t()) ::
  {:ok, ArchAstro.Channel.t()} | {:error, ArchAstro.Error.reason()}

leave(channel)

@spec leave(ArchAstro.Channel.t()) :: :ok | {:error, ArchAstro.Error.reason()}

subscribe_tasks_updated(channel, subscriber \\ self())

@spec subscribe_tasks_updated(ArchAstro.Channel.t(), pid()) :: :ok