Skip to content

Instantly share code, notes, and snippets.

@benjaminudoh10
Created January 4, 2023 11:02
Show Gist options
  • Select an option

  • Save benjaminudoh10/a0d7abc71a450b2f9bf678854787df22 to your computer and use it in GitHub Desktop.

Select an option

Save benjaminudoh10/a0d7abc71a450b2f9bf678854787df22 to your computer and use it in GitHub Desktop.

Revisions

  1. benjaminudoh10 created this gist Jan 4, 2023.
    21 changes: 21 additions & 0 deletions processors.default.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import { Job } from 'bullmq';
    import { JobType, Queues } from '../enum/queue.enum';
    import QueueService from '../services/queue.service';

    // these enums should be in a separate file and exported
    enum Queues {
    DEFAULT = 'default',
    }

    enum JobType {
    PROCESS_PAYMENT = 'process-payment',
    }

    export default class DefaultProcessor {
    static async processPayment(job: Job) {
    const queue = new QueueService().getQueue(Queues.DEFAULT);
    if (!queue) return;

    console.log(`Process job with id ${job.id} from the ${Queues.DEFAULT} queue`);
    }
    }