oban v2.7.0 Release Notes
Release Date: 2021-05-25 // almost 3 years ago-
๐ Pluggable Notifier
The PubSub functionality Oban relies on for starting, stopping, scaling, and pausing queues is now pluggable. The previous notifier was hard-coded to use Postgres for PubSub via
LISTEN/NOTIFY
. Unfortunately,LISTEN/NOTIFY
doesn't work for PG Bouncer in "Transaction Mode." While relatively few users run in "Transaction Mode," it is increasingly common and deserved a work-around.0๏ธโฃ
Oban.Notifier
defines a minimal behaviour and Oban ships with a default implementation,Oban.PostgresNotifier
, based on the oldLISTEN/NOTIFY
๐ง module. You can specify a different notifier in your Oban configuration:config :my_app, Oban, notifier: MyApp.CustomNotifier, repo: MyApp.Repo, ...
An alternate [
pg/pg2
based notifier][pgn] is available in Oban Pro.Replacing Opts on Unique Conflict
โก๏ธ The
replace_args
option for updating args on unique conflict is replaced with โก๏ธ a highly flexiblereplace
option. Usingreplace
, you can update any job field when there is a conflict. Replace works for any of the following fields: โฑargs
,max_attempts
,meta
,priority
,queue
,scheduled_at
,tags
, ๐ทworker
.For example, to change the
priority
to 0 and increasemax_attempts
to 5 when there is a conflict:BusinessWorker.new( args, max_attempts: 5, priority: 0, replace: [:max_attempts, :priority] )
โฑ Another example is bumping the scheduled time to 1 second in the future on โฑ conflict. Either
scheduled_at
orschedule_in
values will work, but the โฑ replace option is alwaysscheduled_at
.UrgentWorker.new(args, schedule_in: 1, replace: [:scheduled_at])
โ Added
๐ท [Oban.Job] A new
conflict?
field indicates whether a unique job conflicted with an existing job on insert.[Oban.Telemetry] Always populate the
unsaved_error
field forerror
ordiscard
events. Previously, the field was empty fordiscard
events.๐ท [Oban.Queue.Engine] Define a
cancel_job/2
callback in the engine and move cancellation from the query module to theBasicEngine
.
๐ Changed
๐จ [Oban.Testing] Thanks to a slight refactoring, the
perform_job/3
helper now emits the same telemetry events that you'd have in production. The refactoring also exposed and fixed an inconsistency around invalid snooze handlers.โ [Oban.Testing] Expose
Testing.all_enqueued/0
, an alternate clause that doesn't require any options. This new clause makes it possible to check for any enqueued jobs without filters.๐ [Oban.Plugins.Stager] Limit the number of jobs staged at one time to prevent timeout errors while staging a massive number of jobs.
๐ Fixed
- [Oban.Repo] Respect ongoing transactions when using
get_dynamic_repo
. Prior to this fix, calls that useOban.Repo
, such asOban.insert/2
, could use a different repo than the one used in the current transaction.