View Source Oban.Config (Oban v2.17.7)

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.



Generate a Config struct after normalizing and verifying Oban options.

Verify configuration options.


@type t() :: %Oban.Config{
  dispatch_cooldown: pos_integer(),
  engine: module(),
  get_dynamic_repo: nil | (-> pid() | atom()),
  insert_trigger: boolean(),
  log: false | Logger.level(),
  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: timeout(),
  stage_interval: timeout(),
  testing: :disabled | :inline | :manual


@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.


Generate a minimal config with only a :repo: Oban.Test.Repo)
@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.


Validating top level options:

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

iex> Oban.Config.validate(name: Oban, log: false)

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.Plugins.Pruner, max_age: 60}])

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