This release includes numerous engine and telemetry improvements which require Oban v2.14+
🏗️ Enhanced Structured Workers
Structured workers are extended with support for type validation, type casting, enum validation,
nested structures, and required field checks at arbitrary depths. The following example
demonstrates type checking, required annotations, enums, and nested structures:
use Oban.Pro.Worker, structured: [
id: {:*, :id},
name: {:*, :string},
mode: ~w(enabled disabled paused)a,
data: [total: {:*, :float}, notes: :string]
]
On new/
keys and types are validated, and errors bubble up to prevent insertion:
StructuredWorker.new(%{id: "not-an-id", mode: "unknown"}).valid?
# => false (invalid id, invalid mode, missing name)
StructuredWorker.new(%{id: "123", mode: "enabled"}).valid?
# => false (missing name)
StructuredWorker.new(%{id: "123", name: "NewBiz", mode: "enabled"}).valid?
# => true
The args
, which are stored as JSON in the database, are then cast prior before passing to
process/1
:
# {"id":123,"name":"NewBiz","mode":"enabled","data":{"parent_id":456}}
%MyApp.StructuredWorker{
id: 123,
name: "NewBiz",
mode: :enabled,
data: %{parent_id:456}
}
Existing users of structured workers don’t worry—the legacy keys
and required
fields are
automatically translated to the new syntax.
See the Oban.Pro.Worker
docs to learn more about structured options.
📗 Consistent Module Docs
Documentation for all plugins, and most extensions, is now in moduledocs rather than guides. The
move exposes function and callbacks docs, typespecs, and retains the guide’s overview for the
module.
Take a look at some of the plugin docs for a taste:
Enhancements
-
[SmartEngine] Remove database backed running_ids
tracking to minimize database churn.
Tracking ids on the producer record in the database is no longer necessary for global
coordination and it causes excessive vacuum load, particularly for AWS Aurora databases.
-
[DynamicPruner] Remove transaction wrapping each pruning run.
Partial progress is better than no progress, and each sub-transaction has it’s own timeout
applied.
-
[Workflow] Halt incomplete workflows with :cancel
rather than :discard
Discarding based on a {:discard, _}
return value is deprecated and cancelling has identical
functionality.
Bug Fixes
-
[DynamicCron] Correctly handle paused: false
in a crontab update.
Previously, change tracking ignored false
because it was the default value.
-
[SmartEngine] Clean up registred producers after queues terminate.
The registry cleans up after register/3
, but it doesn’t ever clean put_meta/3
values. Not
only does that cause bloat over time for dynamic queues, it also makes it look as if processes
are alive when they aren’t.
-
[SmartEngine] Ignore errors caused when recording paused
on shutdown.
An application’s shutdown sequence could cause queue shutdown to raise an error, preventing
graceful shutdown.
Deprecations
-
[Reprioritizer] Renamed to
DynamicPrioritizer
for consistency.