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

Concurrency control for jobs.

Allows limiting the number of concurrent jobs per concurrency key,
and throttling job enqueueing/execution.

# `check_enqueue_limit`

Checks if a job can be enqueued based on concurrency limits.

Returns `{:ok, :ok}` if allowed.

If the limit or throttle is exceeded, or the advisory lock could not be taken, the result is
`{:ok, {:error, reason}}` where `reason` is `:limit_exceeded`, `:throttle_exceeded`, or
`:lock_failed`. That shape comes from `Ecto.Repo.transaction/1` wrapping the callback return
value (not a rolled-back transaction).

# `check_perform_limit`

Checks if a job can be performed based on concurrency limits.

Returns `{:ok, :ok}` if allowed.

Otherwise returns `{:ok, {:error, reason}}` with `reason` in `:limit_exceeded`, `:throttle_exceeded`,
or `:lock_failed` (see `check_enqueue_limit/2` for why this is `{:ok, {:error, _}}`).

---

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