20 lines
565 B
TypeScript
20 lines
565 B
TypeScript
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,
|
|
);
|
|
}
|
|
}
|