The type of the output when the sleeping task is woken up
const waitForWebhook = executor
.sleepingTask<{ webhookId: string }>({
id: 'waitForWebhook',
timeoutMs: 24 * 60 * 60 * 1000, // 24 hours
})
// Enqueue the sleeping task
const handle = await executor.enqueueTask(waitForWebhook, 'uniqueId')
// Wakeup using the unique id and executor (or execution client)
await executor.wakeupSleepingTaskExecution(waitForWebhook, 'uniqueId', {
status: 'completed',
output: {
webhookId: '123',
},
})
// Or, wakeup in a webhook or event handler asynchronously using the unique id and executor
// (or execution client)
await executor.wakeupSleepingTaskExecution(waitForWebhook, 'uniqueId', {
status: 'completed',
output: {
webhookId: '123',
},
})
Options for a task that is asleep until it is marked completed or failed or timed out or cancelled. It is similar to TaskOptions but it does not have a
run
function. It just sleeps until it is marked completed or failed or timed out or cancelled.It is not very useful by itself but when combined with ParentTaskOptions, it can be used to create a task that is a parent task that runs a child task that is asleep until it is marked completed by a webhook or some other event.
See the task examples section for more details on creating tasks.