taskforcesh / bullmq-pro-support

Support repository for BullMQ Pro edition.
1 stars 0 forks source link

How can I write WorkerListener whit WorkerPro? #57

Closed 0xuhe closed 1 year ago

0xuhe commented 1 year ago

Like subject said, how can I code with WokerListener?


import { Job, JobPro, QueuePro, WorkerPro } from "@taskforcesh/bullmq-pro";

(async () => { 
  const queue = new QueuePro("test");

  const worker = new WorkerPro(
    "test",
    async (job: JobPro) => {
      await sleep(10e3);
    },
    {
      group: {
        concurrency: 1,
      },
      concurrency: 20,
    }
  ) ;

// typeError on JobPro in VScode 
//
// Argument of type '(job: JobPro) => void' is not assignable to parameter of type '(job: Job<any, any, string>, prev: string) => void'.
//  Types of parameters 'job' and 'job' are incompatible.
//    Type 'Job<any, any, string>' is missing the following properties from type 'JobPro<any, any, string>': gid, 
// moveBatchToCompleted, moveBatchToFailed, setBatch, and 2 more

  worker.on("active", (job: JobPro) => {
    console.log("actived", job.data);
  });
})();
0xuhe commented 1 year ago

My mistake. I could omit job type

worker.on("active", (job)=> {
    console.log("actived", job.data);
  });