Home

Awesome

<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/oban-bg/oban/main/assets/oban-logotype-dark.png"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/oban-bg/oban/main/assets/oban-logotype-light.png"> <img alt="Oban logo" src="https://raw.githubusercontent.com/oban-bg/oban/main/assets/oban-logotype-light.png" width="320"> </picture> </p> <p align="center"> Robust job processing in Elixir, backed by modern PostgreSQL, MySQL, and SQLite3. Reliable, <br /> observable, and loaded with <a href="#features">enterprise grade features</a>. </p> <p align="center"> <a href="https://hex.pm/packages/oban"> <img alt="Hex Version" src="https://img.shields.io/hexpm/v/oban.svg"> </a> <a href="https://hexdocs.pm/oban"> <img alt="Hex Docs" src="http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat"> </a> <a href="https://github.com/oban-bg/oban/actions"> <img alt="CI Status" src="https://github.com/oban-bg/oban/workflows/ci/badge.svg"> </a> <a href="https://opensource.org/licenses/Apache-2.0"> <img alt="Apache 2 License" src="https://img.shields.io/hexpm/l/oban"> </a> </p>

Table of Contents


[!NOTE]

This README is for the unreleased main branch, please reference the official documentation on hexdocs for the latest stable release.


Features

Oban's primary goals are reliability, consistency and observability.

Oban is a powerful and flexible library that can handle a wide range of background job use cases, and it is well-suited for systems of any size. It provides a simple and consistent API for scheduling and performing jobs, and it is built to be fault-tolerant and easy to monitor.

Oban is fundamentally different from other background job processing tools because it retains job data for historic metrics and inspection. You can leave your application running indefinitely without worrying about jobs being lost or orphaned due to crashes.

Advantages Over Other Tools

Advanced Features

Oban Web+Pro

[!TIP]

A web dashboard for managing Oban, along with an official set of extensions, plugins, and workers that expand what Oban is capable of are available as licensed packages:

Learn more at oban.pro!

<!-- MDOC -->

Engines

Oban ships with engines for PostgreSQL, MySQL, and SQLite3. Each engine supports the same core functionality, though they have differing levels of maturity and suitability for production.

Requirements

Oban requires:

Installation

See the installation guide for details on installing and configuring Oban in your application.

Quick Getting Started

  1. Configure queues and an Ecto repo for Oban to use:

    # In config/config.exs
    config :my_app, Oban,
      repo: MyApp.Repo,
      queues: [mailers: 20]
    
  2. Define a worker to process jobs in the mailers queue (see Oban.Worker):

    defmodule MyApp.MailerWorker do
      use Oban.Worker, queue: :mailers
    
      @impl Oban.Worker
      def perform(%Oban.Job{args: %{"email" => email} = _args}) do
        _ = Email.deliver(email)
        :ok
      end
    end
    
  3. Enqueue a job (see the documentation):

    %{email: %{to: "foo@example.com", body: "Hello from Oban!"}}
    |> MyApp.MailerWorker.new()
    |> Oban.insert()
    
  4. The magic happens! Oban executes the job when there is available bandwidth in the mailer queue.

Learning

Learn the fundamentals of Oban, all the way through to preparing for production with our LiveBook powered Oban Training curriculum.

<!-- MDOC -->

Community

There are a few places to connect and communicate with other Oban users:

Contributing

To run the Oban test suite you must have PostgreSQL 12+ and MySQL 8+ running. Follow these steps to create the database, create the database and run all migrations:

mix test.setup

To ensure a commit passes CI you should run mix test.ci locally, which executes the following commands: