View Source Oban.Config (Oban v2.13.0)

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.

Link to this section Summary

Functions

Generate a Config struct after normalizing and verifying Oban options.

Verify configuration options.

Link to this section Types

@type t() :: %Oban.Config{
  dispatch_cooldown: pos_integer(),
  engine: module(),
  get_dynamic_repo: nil | (() -> pid() | atom()),
  log: false | Logger.level(),
  name: Oban.name(),
  node: String.t(),
  notifier: module(),
  peer: false | module(),
  plugins: false | [module() | {module() | Keyword.t()}],
  prefix: String.t(),
  queues: false | [{atom() | binary(), pos_integer() | Keyword.t()}],
  repo: module(),
  shutdown_grace_period: timeout(),
  testing: :disabled | :inline | :manual
}

Link to this section Functions

@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

Example

Generate a minimal config with only a :repo:

Oban.Config.new(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.

Example

Validating top level options:

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

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

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

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

Validating plugin options:

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

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