View Source DSL: AshOban

Tools for working with AshOban triggers.

oban

Nested DSLs

Examples

oban do
  triggers do
    trigger :process do
      action :process
      where expr(processed != true)
      worker_read_action(:read)
    end
  end
end

Options

NameTypeDefaultDocs
domainmoduleThe Domain to use when calling actions on this resource. Defaults to the resource's domain.

oban.triggers

Nested DSLs

Examples

triggers do
  trigger :process do
    action :process
    where expr(processed != true)
    worker_read_action(:read)
  end
end

oban.triggers.trigger

trigger name

Examples

trigger :process do
  action :process
  where expr(processed != true)
  worker_read_action(:read)
end

Arguments

NameTypeDefaultDocs
nameatomA unique identifier for this trigger.

Options

NameTypeDefaultDocs
actionatomThe action to be triggered. Defaults to the identifier of the resource plus the name of the trigger
action_inputmapStatic inputs to supply to the update/destroy action when it is called. Any metadata produced by read_metadata will overwrite these values.
scheduler_queueatomThe queue to place the scheduler job in. The same queue as job is used by default (but with a priority of 1 so schedulers run first).
debug?booleanfalseIf set to true, detailed debug logging will be enabled for this trigger. You can also set config :ash_oban, debug_all_triggers?: true to enable debug logging for all triggers.
scheduler_cronString.t | false"* * * * *"A crontab configuration for when the job should run. Defaults to once per minute (" *"). Use false to disable the scheduler entirely.
stream_batch_sizepos_integerThe batch size to pass when streaming records from using Ash.stream!/2. No batch size is passed if none is provided here, so the default is used.
queueatomThe queue to place the worker job in. The trigger name is used by default.
record_limitpos_integerIf set, any given run of the scheduler will only ever schedule this many items maximum
log_errors?booleantrueWhether or not to log errors that occur when performing an action.
log_final_error?booleantrueIf true, logs that an error occurred on the final attempt to perform an action even if log_errors? is set to false.
worker_prioritynon_neg_integer2A number from 0 to 3, where 0 is the highest priority and 3 is the lowest.
scheduler_prioritynon_neg_integer3A number from 0 to 3, where 0 is the highest priority and 3 is the lowest.
max_scheduler_attemptspos_integer1How many times to attempt scheduling of the triggered action.
max_attemptspos_integer1How many times to attempt the job. After all attempts have been exhausted, the scheduler may just reschedule it. Use the on_error action to update the record to make the scheduler no longer apply.
read_metadata(any -> any)Takes a record, and returns metadata to be given to the update action as an argument called metadata.
state:active | :paused | :deleted:activeDescribes the state of the cron job. See the getting started guide for more information. The most important thing is that you do not remove a trigger from a resource if you are using oban pro.
read_actionatomThe read action to use when querying records. Defaults to the primary read. This action must support keyset pagination.
worker_read_actionatomThe read action to use when fetching the individual records for the trigger. Defaults to read_action. If you customize this, ensure your action handles scenarios where the trigger is no longer relevant.
whereanyThe filter expression to determine if something should be triggered
on_erroratomAn update action to call after the last attempt has failed. See the getting started guide for more.

Introspection

Target: AshOban.Trigger

oban.scheduled_actions

A section for configured scheduled actions. Supports generic and create actions.

Nested DSLs

Examples

scheduled_actions do
  schedule :import, "0 */6 * * *", action: :import
end

oban.scheduled_actions.schedule

schedule name, cron

Arguments

NameTypeDefaultDocs
nameatomA unique identifier for this scheduled action.
cronString.tThe schedule in crontab notation

Options

NameTypeDefaultDocs
action_inputmapInputs to supply to the action when it is called.
actionatomThe generic or create action to call when the schedule is triggered.
queueatomThe queue to place the job in. Defaults to the resources short name plus the name of the scheduled action (not the action name).
state:active | :paused | :deleted:activeDescribes the state of the cron job. See the getting started guide for more information. The most important thing is that you do not remove a scheduled action from a resource if you are using oban pro.
max_attemptspos_integer1How many times to attempt the job. The action will receive a last_oban_attempt? argument on the last attempt, and you should handle errors accordingly.
prioritynon_neg_integer3A number from 0 to 3, where 0 is the highest priority and 3 is the lowest.
debug?booleanfalseIf set to true, detailed debug logging will be enabled for this trigger. You can also set config :ash_oban, debug_all_triggers?: true to enable debug logging for all triggers.

Introspection

Target: AshOban.Schedule