v2.20.0
This release brings a fantastic new helper function, an optional migration to aid pruning, some stability improvements, and a bevy of documentation updates.
๐ฆ Update Job
This introduces the Oban.update_job/2,3 function to simplify updating existing jobs while ensuring data consistency and safety. Previously, updating jobs required manually constructing change operations or complex queries that could lead to race conditions or invalid state changes.
Only a curated subset of job fields, e.g. :args, :max_attempts, :meta, etc. may be updated and they use the same validation rules as insertion to prevent invalid data. Updates are also wrapped in a transaction with locking clauses to prevent concurrent modifications.
The function supports direct map changes:
Oban.update_job(job, %{priority: 0, tags: ["urgent"]})
It also has a convenient function-based mode for dynamic changes:
Oban.update_job(job, fn job ->
%{meta: Map.put(job.meta, "processed_by", current_node())}
end)
โ๏ธ Unique State Groups
There are now named unique state groups to replace custom state lists for unique jobs, promoting better uniqueness design and reducing configuration errors.