defmodule Oban.Pro.Limiter do
  @moduledoc false

  alias Oban.{Config, Job}
  alias Oban.Pro.Producer

  @type changes :: %{
          :conf => Config.t(),
          :prod => Producer.t(),
          :running => map(),
          optional(atom()) => any()
        }

  @type demand :: non_neg_integer()

  @type limit :: nil | demand | [{demand, term(), term()}]

  @doc """
  Calculate the current demand based on capacity and usage.
  """
  @callback check(changes()) :: {:ok, limit()}

  @doc """
  Record demand usage.
  """
  @callback track(Producer.meta(), [Job.t()]) :: Producer.meta()
end
