1 import Bull from "bull";
3 type TaskHandler<T> = (task: Task<T>, job: Bull.Job<T>) => void;
8 handler: TaskHandler<T>;
9 constructor(name: string, handler: TaskHandler<T>) {
11 this.queue = new Bull(this.name);
16 onJob(handler: TaskHandler<T>) {
17 this.queue.process(job => {
22 trigger(data: T, opts?: Bull.JobOptions) {
23 this.queue.add(data, opts);