Oban-based async processor for reliable background processing.
Requires oban as a dependency and proper Oban configuration in your app.
Unlike the default Task-based processor, Oban jobs are persisted to the
database, survive application restarts, and support automatic retries with
configurable backoff.
Setup
Add
:obanto your dependencies and configure it:# mix.exs {:oban, "~> 2.18"} # config/config.exs config :my_app, Oban, repo: MyApp.Repo, queues: [media: 10]Tell PhxMediaLibrary to use the Oban adapter:
config :phx_media_library, async_processor: PhxMediaLibrary.AsyncProcessor.Oban
Queue Configuration
The worker uses the :media queue by default. Adjust concurrency to
match your server's CPU/memory capacity:
# Low-traffic app
queues: [media: 5]
# High-traffic app with beefy servers
queues: [media: 20]Retry Behaviour
The ProcessConversions worker is configured with max_attempts: 3.
Failed jobs use Oban's default exponential backoff. You can monitor
failed jobs via Oban's built-in dashboard or Oban.Web.
How It Works
When media is uploaded and conversions are defined, the processor enqueues
an Oban job with the media ID, the conversion names, and the mediable_type
so the worker can look up the originating model module and retrieve the full
Conversion definitions (with dimensions, quality, fit mode, etc.).
This avoids the pitfall of serializing only conversion names and losing all
configuration — the previous implementation created empty Conversion structs
with only a :name field.
Summary
Functions
Process conversions synchronously, bypassing the Oban queue.