Skip to content

Commit

Permalink
fix: remove old usage of QueueScheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Dec 18, 2023
1 parent cda599b commit 262ad47
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 151 deletions.
35 changes: 17 additions & 18 deletions examples/with-fastify-auth/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Queue: QueueMQ, Worker, QueueScheduler } = require('bullmq');
const { Queue: QueueMQ, Worker } = require('bullmq');
const fastify = require('fastify');
const { basicAuth } = require('./basicAuth');
const { cookieAuth } = require('./cookieAuth');
Expand All @@ -15,24 +15,23 @@ const redisOptions = {
const createQueueMQ = (name) => new QueueMQ(name, { connection: redisOptions });

async function setupBullMQProcessor(queueName) {
const queueScheduler = new QueueScheduler(queueName, {
connection: redisOptions,
});
await queueScheduler.waitUntilReady();

new Worker(queueName, async (job) => {
for (let i = 0; i <= 100; i++) {
await sleep(Math.random());
await job.updateProgress(i);
await job.log(`Processing job at interval ${i}`);

if (Math.random() * 200 < 1) throw new Error(`Random error ${i}`);
new Worker(
queueName,
async (job) => {
for (let i = 0; i <= 100; i++) {
await sleep(Math.random());
await job.updateProgress(i);
await job.log(`Processing job at interval ${i}`);

if (Math.random() * 200 < 1) throw new Error(`Random error ${i}`);
}

return { jobId: `This is the return value of job (${job.id})` };
},
{
connection: redisOptions,
}

return { jobId: `This is the return value of job (${job.id})` };
}, {
connection: redisOptions,
});
);
}

const run = async () => {
Expand Down
Loading

0 comments on commit 262ad47

Please sign in to comment.