UNPKG

blazerjob

Version:

TypeScript library for scheduling, executing, and managing asynchronous tasks (custom, HTTP) with a SQLite backend.

24 lines (23 loc) 912 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../index"); // Initialize BlazeJob with a test database const jobs = new index_1.BlazeJob({ dbPath: './custom_retry_test.db' }); // Exemple minimal de tâche custom avec juste un console.log const taskId = jobs.schedule(async () => { console.log('[CUSTOM] Hello from my custom BlazeJob task!'); // Pour tester le retry, décommente la ligne suivante : // throw new Error('Erreur custom'); }, { runAt: new Date(Date.now()), // dans 1 seconde interval: 1, retriesLeft: 2, // Essaie 3 fois au total si erreur type: 'custom', config: { foo: 'bar' }, maxRuns: 10, onEnd: ({ runCount, errorCount }) => { console.log('[CUSTOM][onEnd] runCount:', runCount, 'errorCount:', errorCount); process.exit(0); // Pour arrêter le test proprement } }); jobs.start();