prop/vendor/oban_pro/usage-rules/chains.md
Graham McIntire e99bf06eb4
deps: re-vendor oban_pro 1.7.0 (revert hex-repo dep)
Previous commit (3c988a5f) switched oban_pro to the licensed hex
repo at deploy time. Reverting that — keep all three Pro packages
vendored so prod image builds don't depend on oban.pro reachability
or auth on every CI run.

oban_pro 1.7.0 dropped into vendor/oban_pro via
`mix hex.package fetch oban_pro 1.7.0 --repo=oban --unpack`. mix.exs
goes back to `path: "vendor/oban_pro"` (matching oban_met / oban_web,
which were already vendored — and stay vendored since the licensed
repo only has older versions of those: 0.1.11 / 2.10.6 vs the
1.1.0 / 2.12.1 we vendor).

Schema migration from 3c988a5f stays — 1.7.0 tables/indexes are
already applied. No code changes.
2026-04-30 09:29:55 -05:00

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