AshWorkflow.Scheduler.Oban (AshWorkflow v0.6.0)

Copy Markdown View Source

Runs a workflow's scheduled work through ash_oban. The default scheduler.

Each AshWorkflow.Scheduler.Work becomes an AshOban trigger whose where is the work's match expression, so ash_oban discovers eligible records by polling rather than being told about deadlines. That makes the polling interval the floor on accuracy: cron cannot ask for less than a minute, which is why AshWorkflow.Verifiers.ValidateTimeoutPrecision rejects a shorter deadline.

The resource must add the AshOban extension

AshWorkflow does not add it. A workflow using a scheduler that has nothing to do with Oban should not carry the ash_oban DSL, so the extension goes where the choice is made:

use Ash.Resource,
  domain: MyApp.Domain,
  data_layer: AshPostgres.DataLayer,
  extensions: [AshWorkflow, AshOban]

Omitting it while this scheduler is selected is a compile error naming the fix.

Options

  • :queue — the Oban queue for every generated trigger. Defaults to the workflow block's queue.
  • :check_interval — the cron for every generated trigger. Defaults to the workflow block's check_interval. A timeout's own check_interval still overrides it.

Retry

A step's or timeout's retry block becomes the generated trigger's max_attempts and backoff. ash_oban runs the step's on_error action only after the final attempt has failed, which is the same rule AshWorkflow.Scheduler.execute/3 documents.

Module names

Worker and scheduler module names are derived from the resource, the step and the timeout, and are set explicitly rather than left to ash_oban's defaults so that renaming a step does not leave jobs pointing at a module that no longer exists.