Bumps vendored Oban Pro from 1.6.13 to 1.7.0, which transitively bumps oban core to 2.22.1 (requires migrations v14) and db_connection to 2.10.0. - mix.exs constraint: ~> 1.6 → ~> 1.7 - vendor/oban_pro/ replaced with v1.7.0 hex package - migration 20260430142200: Oban core v12 → v14 (must run first) - migration 20260430142241: Oban Pro 1.7.0 schema additions Also corrects a pre-existing constraint name in AgentAssignment that was left stale by the equipment→devices rename migration (20260117190134). The unique index is named agent_assignments_device_id_index, but the schema's unique_constraint/3 still pointed at the old equipment_id name, causing the test suite to surface Ecto.ConstraintError instead of a changeset error. Required to get the suite green for this upgrade.
34 lines
989 B
Markdown
34 lines
989 B
Markdown
# Chains
|
|
|
|
Chains ensure jobs run sequentially for the same entity. Use when order matters (e.g., webhook processing, account balance updates).
|
|
|
|
```elixir
|
|
defmodule MyApp.WebhookWorker do
|
|
use Oban.Pro.Worker,
|
|
queue: :webhooks,
|
|
chain: [by: [args: :account_id]]
|
|
|
|
@impl Oban.Pro.Worker
|
|
def process(%Oban.Job{args: args}) do
|
|
MyApp.Account.handle_webhook(args["account_id"], args["event"])
|
|
end
|
|
end
|
|
```
|
|
|
|
## Partitioning
|
|
|
|
```elixir
|
|
chain: [by: :worker] # All jobs of this worker chain together
|
|
chain: [by: [args: :account_id]] # Chain by account_id across workers
|
|
chain: [by: [:worker, args: :account_id]] # Chain by worker AND account_id
|
|
chain: [by: [args: [:account_id, :region]]] # Chain by multiple args
|
|
```
|
|
|
|
## Handling failures
|
|
|
|
```elixir
|
|
chain: [by: [args: :id], on_discarded: :hold, on_cancelled: :hold]
|
|
```
|
|
|
|
- `:ignore` (default) — continue processing downstream jobs
|
|
- `:hold` — stop the chain until the failed job is resolved
|