oban v0.7.0 Release Notes
Release Date: 2019-08-08 // over 4 years ago-
โ Added
[Oban] Added
insert/2
,insert!/2
andinsert/4
as a convenient and more powerful way to insert jobs. Features such as unique jobs and the upcoming prefix support only work withinsert
.๐ท [Oban] Add
prefix
support. This allows entirely isolated job queues within the same database.โ๏ธ [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
unique
option. Set a unique period, and optionallyfields
andstates
, 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/1
callback in favor ofperform/2
. The newperform/2
function 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/2
function is not generated automatically by theuse
macro 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.Job
struct then you can migrate your workers by adding a second_job
argument:def perform(%{"some" => args}, _job)
If you were making use of
Oban.Job
metadata inperform/1
then 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/3
instead of:timer.send_interval/2
to maintain scheduled dispatch. This mechanism is more accurate under system load and it prevents:poll
messages from backing up for each producer.[Oban.Migration] Accept a keyword list with
:prefix
and:version
as 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")