Styx

Robust job processing in Elixir, backed by modern PostgreSQL, MySQL, and SQLite3. Reliable,
observable, and loaded with enterprise grade features.

Hex Version Hex Docs CI Status Apache 2 License

Table of Contents


Features

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

Styx 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.

Styx 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

Engines

Styx 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

Styx requires:

Installation

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

Quick Getting Started

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

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

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

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

Learning

Refer to the included guides in guides/ for topics covering defining queues, job lifecycle, scheduling, unique jobs, testing, and operational maintenance.

Provenance

Styx is derived from Oban, originally created by Parker Selbert. Styx is an independent open-source project and is not affiliated with, endorsed by, or sponsored by Sorensen Selbert LLC or the upstream Oban project.

Contributing

To run the Styx test suite you must have PostgreSQL 14+ and MySQL 8+ running. Follow these steps to 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: