Tasks are functions that can run for a long time and provide strong resilience to failure.
task
id
fieldrun
functionrun()
will be executed when your task is triggered. It’s an async function that has two arguments:
ctx
about the run (Context), and any output from the optional init
function that runs before every run attempt.run
function will be the result of the task. Data you return must be JSON serializable: strings, numbers, booleans, arrays, objects, and null.
retry
optionsretry
field:
queue
optionsmachine
optionsmachine
field. For more information read the machines guide.
init
functioncleanup
functionmiddleware
functionrun
function, it allows you to wrap the run function with custom code. For more information read the guide.
onSuccess
functiononSuccess
function is called. It’s useful for sending notifications, logging, or other side effects.
onError
functiononError
function is called. It’s useful for sending notifications, logging, or other side effects.