Skip to content

Instantly share code, notes, and snippets.

View andypearson's full-sized avatar

Andy Pearson andypearson

View GitHub Profile
@sorentwo
sorentwo / oban_from_rails.md
Created August 22, 2022 20:02
Guide for inserting Oban jobs from Rails

Migrating background jobs to Elixir is easy with Oban because everything lives in your PostgreSQL database. Oban relies on a structured oban_jobs table as its job queue, and purposefully uses portable data structures (JSON) for serialization. That makes it enqueueing jobs into Oban simple for any language with a PostgreSQL adapter, no Oban client necessary.

As a demonstration, let's explore inserting Oban jobs from a Rails application.

To start, define a skeletal ActiveRecord model with a few conveniences for scheduling jobs: