# `JoobQ.Config`
[🔗](https://github.com/azutoolkit/joobqui/tree/master/sdks/elixir/blob/main/lib/joobq/config.ex#L2)

The options of one JoobQ instance, as given to `{JoobQ, opts}` in a supervision tree.

  * `:url` (required): the JoobQUI server's origin, e.g. `"https://joobqui.example.com"`, without user info, query
    or fragment. `http://` is refused unless the host is loopback (`localhost`, `127.0.0.0/8`, `::1`) or
    `allow_insecure: true` is given: the SDK token travels in every call.
  * `:token` (required): the server's SDK token (`JOOBQUI_SDK_TOKEN` on the server), printable characters only; it is
    trimmed. `inspect/1` and crash reports leave it out: it is kept in a closure, which stops working (`:badfun`) if
    this module is hot-reloaded twice without restarting the instance.
  * `:name`: the instance's name, `JoobQ` by default; pass it as `name:` to every call of another instance.
  * `:request_timeout`: milliseconds one gateway call may take, 60 000 by default.
  * `:pool_size`: kept-alive HTTP connections to the gateway, 50 by default.
  * `:allow_insecure`: `true` lets `:url` be `http://` on any host (development only), `false` by default.

The worker options; the instance runs a worker only when `:queues` is given:

  * `:queues`: the queues the worker takes jobs from, a list of names, `[]` (a producer only) by default.
  * `:workers`: the modules that `use JoobQ.Worker` and run the jobs, `[]` by default; a job of a type none of them
    handles goes to the dead letter queue.
  * `:workflows`: the workflows (`JoobQ.Workflow`) whose steps the worker runs, `[]` by default; each one's
    `task_queue` is added to `:queues`, and its blueprint is registered when the worker starts.
  * `:middleware`: what wraps every job's run, `JoobQ.Middleware` modules or `{module, opts}`, the first
    listed outermost, `[]` by default.
  * `:worker_id`: the worker's id on the Workers page, `"<host>-<os pid>-<name>"` by default.
  * `:concurrency`: jobs run at once, 1 to 1000, 4 by default.
  * `:service`, `:team`: the service and team the Workers page shows, none by default.
  * `:prefetch`: leases held beyond the free slots, so a finished handler finds its next job at once,
    `max(1, div(concurrency, 2))` by default.
  * `:ack_linger`: milliseconds an outcome waits for others to share its call, 5 by default.
  * `:ack_buffer`: outcomes waiting for their call before handlers wait, `4 * concurrency` by default.
  * `:lease_ttl_ms`: a lease's lifetime, renewed every third of it, 1 000 to 300 000, 30 000 by default.
  * `:drain_timeout`: milliseconds a stopping worker has to run what it holds and send the outcomes, 30 000 by
    default; then it deregisters (see the README for the whole bound of a stop).

# `t`

```elixir
@type t() :: %JoobQ.Config{
  ack_buffer: pos_integer(),
  ack_linger: non_neg_integer(),
  concurrency: pos_integer(),
  drain_timeout: non_neg_integer(),
  lease_ttl_ms: pos_integer(),
  middleware: [{module(), term()}],
  name: atom(),
  pool_size: pos_integer(),
  prefetch: non_neg_integer(),
  queues: [String.t()],
  request_timeout: pos_integer(),
  service: String.t() | nil,
  team: String.t() | nil,
  token: function(),
  url: String.t(),
  worker_id: String.t(),
  workers: [module()],
  workflows: [JoobQ.Workflow.t()]
}
```

# `finch`

```elixir
@spec finch(atom()) :: atom()
```

The Finch pool an instance named `name` sends its calls through.

# `new!`

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

The configuration for `opts`; raises `ArgumentError` naming the first option that is wrong.

# `token`

```elixir
@spec token(t()) :: String.t()
```

The SDK token of `config`, for the `Authorization` header only.

# `worker?`

```elixir
@spec worker?(t()) :: boolean()
```

Whether the instance described by `config` runs a worker: it has queues to take jobs from.

---

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