init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
||||
import { Job } from 'bullmq';
|
||||
import { TradeService } from '../modules/trade/trade.service';
|
||||
import { DELIVERY_QUEUE } from './jobs.constants';
|
||||
|
||||
@Processor(DELIVERY_QUEUE)
|
||||
export class DeliveryProcessor extends WorkerHost {
|
||||
constructor(private readonly tradeService: TradeService) {
|
||||
super();
|
||||
}
|
||||
|
||||
async process(job: Job<{ orderId: string; targetStatus: string }>) {
|
||||
await this.tradeService.applyStatusTransition(
|
||||
BigInt(job.data.orderId),
|
||||
'',
|
||||
job.data.targetStatus,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const DELIVERY_QUEUE = 'delivery-mock';
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { BullModule } from '@nestjs/bullmq';
|
||||
import { TradeModule } from '../modules/trade/trade.module';
|
||||
import { DeliveryProcessor } from './delivery.processor';
|
||||
import { DELIVERY_QUEUE } from './jobs.constants';
|
||||
|
||||
@Module({
|
||||
imports: [BullModule.registerQueue({ name: DELIVERY_QUEUE }), TradeModule],
|
||||
providers: [DeliveryProcessor],
|
||||
})
|
||||
export class JobsModule {}
|
||||
Reference in New Issue
Block a user