defmodule Oban.Pro.Stages.Executing do
  @moduledoc false

  @behaviour Oban.Pro.Stage

  @impl Oban.Pro.Stage
  def init(_worker, _opts), do: {:ok, :ignore}

  @impl Oban.Pro.Stage
  def before_process(%{conf: conf} = job, _conf) when is_struct(conf) do
    Registry.register(Oban.Registry, {conf.name, {:executing, job.id}}, nil)

    {:ok, job}
  end

  def before_process(job, _conf), do: {:ok, job}
end
