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 from3c988a5fstays — 1.7.0 tables/indexes are already applied. No code changes.
34 lines
881 B
Markdown
34 lines
881 B
Markdown
# Chunks
|
|
|
|
Chunks process jobs in groups based on size or timeout. Use for bulk operations and batched API calls.
|
|
|
|
```elixir
|
|
defmodule MyApp.BulkIndexer do
|
|
use Oban.Pro.Chunk, size: 100, timeout: 5_000
|
|
|
|
@impl true
|
|
def process([_ | _] = jobs) do
|
|
jobs
|
|
|> Enum.map(& &1.args["document"])
|
|
|> MyApp.Search.bulk_index()
|
|
|
|
:ok
|
|
end
|
|
end
|
|
```
|
|
|
|
## Options
|
|
|
|
- `size: 100` — process up to 100 jobs at once (default)
|
|
- `timeout: 1000` — process after 1 second even if size not reached (default)
|
|
- `by: [args: :tenant_id]` — partition chunks by field
|
|
|
|
## Return values
|
|
|
|
```elixir
|
|
:ok # All jobs succeeded
|
|
{:ok, result} # All jobs succeeded with result
|
|
{:error, reason, failed_jobs} # Some jobs failed, others succeed
|
|
{:cancel, reason, jobs} # Cancel specific jobs
|
|
{:snooze, seconds, jobs} # Snooze specific jobs
|
|
```
|