Skip to content

eseom/bee-queue-scheduler

Repository files navigation

Overview

a simple cron scheduler for bee-queue

Installation

yarn add bee-queue-scheduler

The idea is simple. We can use schedule instead of save. I do not know what to do anymore because these codes fit my requirements. I would like to further develop the code, but if you need more, I would like you to suggest.

Usage

const Queue = require('bee-queue-scheduler');
const queue = new Queue('example');

const job = queue.createJob({x: 2, y: 3})
// job.save();
// simply use schedule method instead of save. that's all!
job.schedule('*/10 * * * * *', 'Asia/Seoul')

// Process the job every 10 seconds
queue.process(function (job, done) {
  console.log(`Processing job ${job.id}`);
  return done(null, job.data.x + job.data.y);
});

Development

# clone
yarn
docker-compose up -d
node example