Oban v0.7.0 has been released!
This release includes a few big features and some breaking changes to workers. The somewhat annotated CHANGELOG follows.
Thanks to everybody who contributed to docs and helped drive these features ![]()
Added
-
[Oban] Added
insert/2,insert!/2andinsert/4as a convenient and more powerful way to insert jobs. Features such as unique jobs and prefix support only work withinsert. -
[Oban] Add
prefixsupport. This allows entirely isolated job queues within the same database. @anthonator -
[Oban.Worker] Compile time validation of all passed options. Catch typos and other invalid options when a worker is compiled rather than when a job is inserted for the first time.
-
[Oban.Worker] Unique job support through the
uniqueoption. Set a unique period, and optionallyfieldsandstates, to enforce uniqueness within a window of time. For example, to make a job unique by args, queue and worker for 2 minutes:use Oban.Worker, unique: [period: 120, fields: [:args, :queue, :worker]]Note, unique support relies on the use of
Oban.insert/2,4.
Changed
-
[Oban.Worker] Remove the
perform/1callback in favor ofperform/2. The newperform/2function receives the job’s args, followed by the complete job struct. This new function signature makes it clear that the args are always available, and the job struct is also there when it is needed. A defaultperform/2function is not generated automatically by theusemacro and must be defined manually.This is a breaking change and all worker modules will need to be updated. Thankfully, due to the behaviour change, warnings will be emitted when you compile after the upgrade.
If your perform functions weren’t matching on the
Oban.Jobstruct then you can migrate your workers by adding a second_jobargument:def perform(%{"some" => args}, _job)If you were making use of
Oban.Jobmetadata inperform/1then you can move the job matching to the second argument:def perform(_args, %{attempt: attempt})See the issue that suggested this change for more details and discussion.
-
[Oban.Producer] Use
send_after/3instead of:timer.send_interval/2to maintain scheduled dispatch. This mechanism is more accurate under system load and it prevents:pollmessages from backing up for each producer. -
[Oban.Migration] Accept a keyword list with
:prefixand:versionas options rather than a single version string. When a prefix is supplied the migration will create all tables, indexes, functions and triggers within that namespace. For example, to create the jobs table within a “private” prefix:Oban.Migrate.up(prefix: "private")t






















