SuperWorker

An Elixir library for supervised background work. Declare workers as plain functions and run them — in long-lived supervised processes, in a partitioned job pool, or as in-process pipelines — without designing a supervision tree upfront.

Note: the library is still unstable, please don't use it in production.

Which primitive do I need?

Need Use Guide
Long-lived processes kept alive, messaged by id, restarted on crash Supervisor (groups, chains, standalone workers) Supervisor Guide
Short jobs submitted to workers, with retries, backoff and backpressure Pool Pool Guide
Data-transformation steps with per-step retry/skip/branch/resume, no processes FunctionChain FunctionChain Guide

Supervisors declared in config files: Config Guide (Quickstart).

60-second quickstart

alias SuperWorker.Supervisor, as: Sup

# A supervisor holding one group worker (see the Supervisor Guide).
{:ok, _} = Sup.start_with_config([id: :sup1, num_partitions: 2, link: false])
{:ok, _} = Sup.add_group(:sup1, [id: :group1, restart_strategy: :one_for_one])
{:ok, _} = Sup.add_group_worker(:sup1, :group1, fn -> do_work() end, [id: :w1])

# Or a pool running jobs (see the Pool Guide).
{:ok, _} = SuperWorker.Pool.start_link(name: MyPool, task: fn job -> do_work(job) end, size: 20)
{:ok, result} = SuperWorker.Pool.run(MyPool, job)

Guides

Start with the chooser above, then read in any order:

Full API reference ships with the docs (mix docs) and in the Hex package.

Features

Planned features