Hey there! Unfortunately we can’t test it the way we want to because we can’t get a license for Oban pro, but its currently in use in multiple apps so even though the automated testing is light, its being battle tested as we speak.
So, generally speaking you don’t need to use
run_trigger/2. The way it works is that there is a
scheduler_cron (which currently defaults to every one minute i.e
"* * * * *") that runs the update action for every record matching its
where option (which by default is everything). For example:
trigger :processing do
where expr(processed != true)
scheduler_cron "* * * * *"
That example is the one from the docs. So that trigger essentially uses itself, assuming you’ve followed the guide and set up the Oban guide.
There are two ways you might enqueue a job manually. Keep in mind it still has to match the conditions listed on the trigger, but it it can basically let you enqueue something without waiting for the scheduler. The first one is using
change run_oban_trigger/ from the action. For example, we might have an action:
update :reprocess do
change set_attribute(:processed, false)
That enqueues the job to process an item immediately, instead of waiting for the scheduler to run and enqueue the job (since it now matches
processed != true, it will get picked up on the next run of the scheduler).
The other way you can do essentially the same thing is with
AshOban.run_trigger/2. This version is when you want to do it dynamically, say something like:
# perhaps in testing or for some reason you have a record and you want to run some trigger
Keep in mind those two manual versions are only necessary if you want to run a trigger manually. The scheduler will run and schedule jobs matching the conditions of the trigger automatically otherwise.
Disabling the schduler
You can also configure
scheduler_cron false. This lets you set up a trigger that will never be automatically scheduled. In which case you will need to do one of the two things listed above to schedule a trigger.
Hopefully that helps! That is a pretty new package, and is definitely very sparse on docs