CouncilEx.Workers.Oban (CouncilEx v0.1.0)

Copy Markdown View Source

Oban worker that wraps a CouncilEx run in a durable, retry-safe job.

Execution semantics:

  • Job survives node restarts. Any node in the cluster can pick it up — the work runs on whichever node Oban schedules.
  • timeout/1 returns :infinity because council runs commonly exceed Oban's 1-minute default. If a hard cap is needed, override via your application's worker (see "Subclassing" below).
  • Worker calls CouncilEx.run/3 (which uses start_link/3 internally), so a worker timeout / kill propagates to the run — runner dies with the worker, no orphan tokens.
  • Each retry receives a new run_id (per-attempt). The original is stored on the run row as :parent_attempt_run_id so the chain is reconstructable.

Args

Job args is a map with:

  • "council" — string. Module name (Module.split form) or "dynamic:<id>". Looked up via String.to_existing_atom/1 so the module must be loaded on every replica.
  • "input" — arbitrary JSON. Passed verbatim to CouncilEx.run/3.
  • "run_id" — string. The id assigned by CouncilEx.start/3 for the first attempt. On retries the worker generates a new id and links it via :parent_attempt_run_id.

Subclassing

If you need a custom queue, max attempts, or args schema, define your own worker that delegates:

defmodule MyApp.CouncilWorker do
  use Oban.Worker, queue: :councils, max_attempts: 3
  @impl true
  def timeout(_), do: :timer.minutes(30)
  @impl true
  def perform(job), do: CouncilEx.Workers.Oban.perform(job)
end