queuetopia v1.4.0 Queuetopia View Source

Defines a queues machine.

A Queuetopia can manage multiple ordered blocking queues. All the queues share only the same scheduler and the same poll interval. They are completely independants.

A Queuetopia expects a performer to exist. For example, the performer can be implemented like this:

defmodule MyApp.MailQueuetopia.Performer do
  @behaviour Queuetopia.Performer

  @impl true
  def perform(%Queuetopia.Queue.Job{action: "do_x"}) do
    do_x()
  end

  defp do_x(), do: {:ok, "done"}
end

And the Queuetopia:

defmodule MyApp.MailQueuetopia do
  use Queuetopia,
    otp_app: :my_app,
    performer: MyApp.MailQueuetopia.Performer,
    repo: MyApp.Repo
end

# config/config.exs
config :my_app, MyApp.MailQueuetopia,
  poll_interval: 60 * 1_000,
  disable?: true