ActiveJob

WIP

Installation

If available in Hex, the package can be installed by adding activejob to your list of dependencies in mix.exs:

def deps do
  [
    {:activejob, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/activejob.

Preliminar API

With oban:

defmodule ActiveJob.ObanJob do
  use ActiveJob.Base,
    queue_adapter: ActiveJob.QueueAdapters.ObanAdapter

  def perform(args) do
    IO.inspect("THE GREAT OBAN JOB WAS PERFORMED!")
    IO.inspect(args)
  end
end

Execute Job async

ObanJob.perform_later(%{a: "David", b: 2})

Execute inline

ObanJob.perform_now(%{a: "David", b: 2})

With inline, for testing:

defmodule ActiveJob.HelloJob do
  use ActiveJob.Base,
    queue_adapter: :inline,

  def perform(greeter) do
    IO.inspect("GREAT THE JOB HAS PERFORMED!")
  end
end

executing:

ObanJob.perform_later(%{a: "David", b: 2})

Other options for enqueueing

  use ActiveJob.Base,
    queue_adapter: :inline,
    queue_as: :aaa,
    callbacks: %{
      before: fn x -> IO.inspect("BEFORE") end,
      after: fn x -> IO.inspect("AFTER") end
    }

Existing Queue libraries in Elixir