Oban.Plugins.Pruner (Oban v2.4.0) View Source

Periodically delete completed, cancelled and discarded jobs based on age.

Using the Plugin

The following example demonstrates using the plugin without any configuration, which will prune jobs older than the default of 60 seconds:

config :my_app, Oban,
  plugins: [Oban.Plugins.Pruner],
  ...

Override the default options to prune jobs after 5 minutes:

config :my_app, Oban,
  plugins: [{Oban.Plugins.Pruner, max_age: 300}],
  ...

Options

  • :max_age — the number of seconds after which a job may be pruned
  • :limit — the maximum number of jobs to prune at one time. The default is 10,000 to prevent request timeouts. Applications that steadily generate more than 10k jobs a minute should increase this value.

Instrumenting with Telemetry

The Oban.Plugins.Pruner plugin adds the following metadata to the [:oban, :plugin, :stop] event:

  • :pruned_count - the number of jobs that were pruned from the database

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

Specs

option() ::
  {:conf, Oban.Config.t()}
  | {:name, GenServer.name()}
  | {:limit, pos_integer()}
  | {:max_age, pos_integer()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.