# `Oban.Config`
[🔗](https://github.com/oban-bg/oban/blob/v2.24.2/lib/oban/config.ex#L1)

The Config struct validates and encapsulates Oban instance state.

Typically, you won't use the Config module directly. Oban automatically creates a Config struct
on initialization and passes it through to all supervised children with the `:conf` key.

To fetch a running Oban supervisor's config, see `Oban.config/1`.

# `t`

```elixir
@type t() :: %Oban.Config{
  dispatch_cooldown: pos_integer(),
  engine: module(),
  get_dynamic_repo: term(),
  insert_trigger: boolean(),
  log: term(),
  name: Oban.name(),
  node: String.t(),
  notifier: {module(), Keyword.t()},
  peer: {module(), Keyword.t()},
  plugins: [module() | {module(), Keyword.t()}],
  prefix: false | String.t(),
  queues: Keyword.t(Keyword.t()),
  repo: module(),
  shutdown_grace_period: non_neg_integer(),
  stager: false | {module(), Keyword.t()},
  testing: :disabled | :inline | :manual
}
```

# `new`

```elixir
@spec new([Oban.option()]) :: t()
```

Generate a Config struct after normalizing and verifying Oban options.

See `Oban.start_link/1` for a comprehensive description of available options.

## Example

Generate a minimal config with only a `:repo`:

    Oban.Config.new(repo: Oban.Test.Repo)

# `validate`

```elixir
@spec validate([Oban.option()]) :: :ok | {:error, String.t()}
```

Verify configuration options.

This helper is used by `new/1`, and therefore by `Oban.start_link/1`, to verify configuration
options when an Oban supervisor starts. It is provided publicly to aid in configuration testing,
as `test` config may differ from `prod` config.

# Example

Validating top level options:

    iex> Oban.Config.validate(name: Oban)
    :ok

    iex> Oban.Config.validate(name: Oban, prefix: "private")
    :ok

    iex> Oban.Config.validate(node: {:not, :binary})
    {:error, "expected :node to be a binary, got: {:not, :binary}"}

    iex> Oban.Config.validate(plugins: true)
    {:error, "invalid value for :plugins, expected :plugins to be a list, got: true"}

Validating plugin options:

    iex> Oban.Config.validate(plugins: [{Oban.Pruner, max_age: {1, :day}}])
    :ok

    iex> Oban.Config.validate(plugins: [{Oban.Pruner, max_age: 0}])
    {:error, "invalid value for :plugins, expected :max_age to be a positive integer or {amount, unit} tuple, got: 0"}

