# `Zizq.Enqueue`
[🔗](https://github.com/zizq-labs/zizq-elixir/blob/v0.8.0/lib/zizq/enqueue.ex#L4)

Job inputs to be enqueued.

Building one sends nothing, so enqueues may compose: you may build
many, then hand them to `Zizq.enqueue_all/2` in a single request bulk
enqueue request.

    Zizq.Enqueue.new!(type: "send_email", payload: %{"user_id" => 42})

## Fields

  * `:type` — the job's type name used by the worker to route to an
    appropriate handler. **Required.** This is the string other
    languages would also enqueue to reach the same handler.
  * `:payload` — arbitrary JSON-compatible data processed by the
    worker. Defaults to `%{}`.
  * `:queue` — defaults to `"default"` on the client. The server
    requires a queue on every enqueue and has no default of its own.
  * `:priority` — 0 to 65535, lower runs first. Defaults to the
    middle of the range (32768) when not specified.
  * `:ready_at` — a `t:DateTime.t/0` (or Unix milliseconds) before
    which the job will not run. Creates it in the `:scheduled` state
    when set to a future date/time.
  * `:retry_limit` — number of attempts before the job is declared
    dead.
  * `:backoff` — a `Zizq.Backoff` policy, or a keyword list.
  * `:retention` — a `Zizq.Retention` policy, or a keyword list.
  * `:unique_key` — enqueue-time deduplication key: a string, or a
    `Zizq.PayloadHasher` to derive one from the payload. `:payload`
    and `{:payload, opts}` are shorthand for the latter. Requires a
    Pro licence on the server.
  * `:unique_while` — `:queued` (default), `:active`, or `:exists`.
  * `:batch` — a `Zizq.BatchConfig`, or a keyword list. Requires a
    Pro licence on the server.

Anything left unset is omitted from the request, so the server's own
defaults apply and continue to track its configuration.

# `t`

```elixir
@type t() :: %Zizq.Enqueue{
  backoff: Zizq.Backoff.t() | nil,
  batch: Zizq.BatchConfig.t() | nil,
  budgets: [Zizq.BudgetBinding.t()],
  payload: term(),
  priority: non_neg_integer() | nil,
  queue: String.t(),
  ready_at: DateTime.t() | integer() | nil,
  retention: Zizq.Retention.t() | nil,
  retry_limit: non_neg_integer() | nil,
  type: String.t(),
  unique_key: String.t() | Zizq.PayloadHasher.t() | nil,
  unique_while: :queued | :active | :exists | nil
}
```

# `new!`

```elixir
@spec new!(t() | keyword() | map()) :: t()
```

Build an enqueue from a keyword list or map.

Unknown keys are rejected rather than ignored. Without that, a typo
like `payloads:` would silently enqueue a job with an empty payload.

---

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