View Source Oban.Plugins.Stager (Oban v2.13.6)

Transition jobs to the :available state when:

  • jobs are :scheduled and the current time is on or after the timestamp specified in :scheduled_at.
  • jobs are :retryable and they don't reach the attempt limit specified by :max_attempts.

Besides changing the state of jobs, this plugin also uses PubSub to notify queues that they have available jobs. This prevents every queue from polling independently and reduces database load.

This module is necessary for the execution of scheduled and retryable jobs. As such, it's started by each Oban instance automatically unless plugins: false is specified.

options

Options

  • :interval - the number of milliseconds between database updates. This is directly tied to the resolution of scheduled jobs. For example, with an interval of 5_000ms, scheduled jobs are checked every 5 seconds. The default is 1_000ms.
  • :limit — the number of jobs that will be staged each time the plugin runs. Defaults to 5,000, which you can increase if staging can't keep up with your insertion rate or decrease if you're experiencing staging timeouts.

instrumenting-with-telemetry

Instrumenting with Telemetry

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

  • :staged_count - the number of jobs that were staged in the database

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Types

@type option() :: Oban.Plugin.option() | {:interval, pos_integer()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.