# `GoodJob.Bulk`
[🔗](https://github.com/amkisko/good_job.ex/blob/v1.0.0/lib/good_job/bulk.ex#L1)

Buffers and enqueues multiple jobs together.

This mirrors the upstream GoodJob::Bulk API:
- `capture/1` captures jobs enqueued within a block.
- `enqueue/1` captures jobs and inserts them atomically in one transaction.
- `enqueue/1` also accepts a list of `%GoodJob.Job.Instance{}`.

# `entry`

```elixir
@type entry() :: %{job_attrs: map(), callback_module: module() | nil, opts: keyword()}
```

# `add`

```elixir
@spec add(entry()) :: {:ok, :buffered} | {:error, :not_buffering}
```

Adds a job entry to the current buffer.

This is used internally by `GoodJob.enqueue/3`.

# `buffering?`

```elixir
@spec buffering?() :: boolean()
```

Returns `true` when the current process is buffering jobs.

# `capture`

```elixir
@spec capture((-&gt; any())) :: [entry()]
```

Captures jobs enqueued inside the given function.

Returns captured job entries.

# `enqueue`

```elixir
@spec enqueue((-&gt; any()) | [GoodJob.Job.Instance.t()]) ::
  {:ok, [GoodJob.Job.t()]} | {:error, any()}
```

Atomically enqueues jobs.

Accepts either:
- a function that enqueues jobs (`perform_later/1`, `GoodJob.enqueue/3`, etc.)
- a list of `%GoodJob.Job.Instance{}`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
