npm

This package has been deprecated

Author message:

this package has been deprecated

adonisjs-bull-queue-provider

1.0.0 • Public • Published

Install

Install with npm:

npm install adonisjs-bull-queue-provider

Install with yarn:

yarn add adonisjs-bull-queue-provider

Config

Make sure to register the provider inside start/app.js file.

const providers = ["adonisjs-bull-queue-provider/BullProvider"];

Config redis with adonis

And then your .env file

  REDIS_HOST=127.0.0.1
  REDIS_PORT=6379

Make a Job

You can initiate a Job using adonis cli

adonis make:job JobName

Import Bull with

use('Bull/Queue')

Using

  • Make a job file with adonis cli
  • Call a job to make a service
const job = await JobName.add("nameJob", { data });

If you will use hooks, you can do this way

const job = await JobName.add("nameJob", { data });
job.waiting(data).completed(data);

Exemple

const Bull = use("Bull/Queue");
class JobName {
  constructor() {
    this.queue = Bull.init("JobName");
    this.process();
  }

  add(name = null, data = null, options = null) {
    // Data to process in queue
    this.queue.add(name, data, options);
    return this.hooks();
  }

  process() {
    this.queue.process("*", async (job, done) => {
      try {
        console.log(job.data);
        done(null, { msg: "done" });
      } catch (error) {
        throw new Error(error);
      }
    });
  }
}

module.exports = new JobName();

Package Sidebar

Install

npm i adonisjs-bull-queue-provider

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.31 kB

Total Files

5

Last publish

Collaborators

  • williamsouzaa