OddJob

Hex pm

Job pools for Elixir OTP applications, written in Elixir.

Installation

The package can be installed by adding odd_job to your list of dependencies in mix.exs:

def deps do
[
{:odd_job, "~> 0.1"}
]
end

Getting Started

You can add job pools directly to the top level of your own application's supervision tree:

defmodule MyApp.Application do
use Application
def start(_type, _args) do
children = [
{OddJob, :email},
{OddJob, :task}
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end

The tuple {OddJob, :email} will return a child spec for a supervisor that will start and supervise the :email pool. The second element of the tuple can be any atom that you want to use as a unique name for the pool.

You can also configure OddJob to supervise your pools for you in a separate supervision tree.

In your config.exs:

config :odd_job,
supervise: [:email, :task]

You can also configure a custom pool size that will apply to all pools:

config :odd_job, pool_size: 10 # the default value is 5

Now you can call on your pools to perform concurrent fire and forget jobs:

OddJob.perform(:email, fn -> send_confirmation_email() end)
OddJob.perform(:task, fn -> update_external_application() end)

Documentation

For more usage, reference the documentation.