Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 505 Bytes

File metadata and controls

23 lines (14 loc) · 505 Bytes

DurableTask

A function, but every execution is archived, queryable, and can be retried on failure. Based on BullMQ primitives: Queue, Worker, QueueEvents.

import { DurableTask } from './src/durable-task.js';

const task = new DurableTask('send-email', async (input, logger) => {
  logger.info(`Processing ${input.to}`);
  return { sent: true };
});

task.startWorker();

await task.callSync({ to: 'user@example.com' });

await task.getHistory();

await sendEmail.retryAllFailed();