Pro Worker
The new Oban.Pro.Worker
is a replacement for Oban.Worker
with expanded
capabilities such as encryption, enforced structure, and output
recording. In addition, because Batch
, Chunk
, and Workflow
workers
are based on the Pro worker, you can use all of the advanced options there as
well.
Here’s a sample worker that’s configured for encryption, recording, and enforced structure:
defmodule MyApp.SuperWorker do
use Oban.Pro.Worker,
queue: :super,
encrypted: [key: {Application, :fetch_env!, :secret_key}],
recorded: true,
structured: [keys: [:id, :ssn, :pin], required: [:id]]
@impl Oban.Pro.Worker
def process(%Job{args: %__MODULE__{} = args}) do
# Use the decrypted and structured args and record the result!
MyApp.Business.predict(args.id, args.ssn, args.pin)
end
end
# After the job runs, use `fetch_recorded` to view the return value
MyApp.SuperWorker.fetch_recorded(job)
# => {:ok, %{business: :done}}
See more in the Pro Worker guide!
Dynamic Queues
The new DynamicQueues
plugin extends Oban’s basic queue management by
persisting changes across restarts, globally, across all connected nodes. It
also boasts a declarative syntax for specifying which nodes a queue will run on.
DynamicQueues
are ideal for applications that dynamically start, stop, or
modify queues at runtime.
Here’s a taste:
plugins: [{
Oban.Pro.Plugins.DynamicQueues,
queues: [
event: 30,
basic: [local_limit: 10, only: {:node, :=~, "web|worker"}],
audio: [local_limit: 20, only: {:node, :=~, "worker"}],
video: [local_limit: 30, only: {:node, :=~, "worker"}],
learn: [local_limit: 10, only: {:sys_env, "EXLA", "CUDA"}]
]
}]
Check out the DynamicQueues guide for installation, configuration, complete typespecs, and a whole lot more reference.
Bug Fixes
-
[DynamicCron] Preserve unchanged attributes such as
paused
,args
, etc. on init. -
[DynamicCron] Respect the current timezone for
@reboot
jobs. Previously,@reboot
expressions were evaluated on boot without the timezone applied. In that case the expression may not match the calculated time and jobs wouldn’t trigger. -
[Chunk] Never calculate a negative timeout for chunks. Previously, during sudden periods of inactivity, it was possible for the waiting period to be negative.
-
[Batch] Ensure callbacks are only inserted once even when the callback condition matches multiple times.
-
[Batch] Overwrite unique keys for batch callbacks insertion to isolate them from any worker configuration.
-
[Batch] Remove
batch_id
match for batch worker perform. It was an unnecessary barrier to unit testing batch jobs.
Deprecations
-
[Lifeline]
Lifeline
is deprecated in favor ofDynamicLifeline
. The goal is to differentiate between the newBasicLifeline
in Oban and the Pro version. -
[PG] The
PG
notifier was moved to Oban and is deprecated. Replace any references toOban.Pro.Plugins.PG
withOban.Plugins.PG
.
Removals
-
[WorkflowManager] The long-deprecated
WorkflowManager
was finally deleted.
Changes
-
[Oban] Require Oban
~> v2.11
to make use of leadership for plugin activity.