Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Workers

Ahmet edited this page Dec 29, 2017 · 14 revisions

Advanced Workers

Below the detailed worker class usage.

class SendEmail {
  retry = 2;

  handle(args, dep1, dep2) {
    try {
      return new Promise((resolve, reject) => {
        resolve(true);
      });
    } catch(e) {
      reject('rejected')
    }
  }
  
  before(args) {
    //
  }
  
  after(args) {
    //
  }
}

Note: The worker classes has two events. before and after

Register:

const user = new User;
const order = new Order;

Queue.register([
  { handler: SendEmail, deps: { user, order } }
]);
Clone this wiki locally