import { Inject , Provide } from '@midwayjs/decorator' ; import { JobOptions , Queue } from 'bull' ; @ Provide ( ) export class QueueService { @ Inject ( 'queueMap' ) queueMap ; @ Inject ( 'queueTaskMap' ) queueTaskMap ; async execute ( queueName , data , options = { } ) { const queue = this . queueMap [ `${ queueName . name }:execute` ] as Queue ; return await queue . add ( data , options ) ; } getClassQueue ( queueName ) { return this . queueMap [ `${ queueName . name }:execute` ] as Queue ; } getQueueTask ( queueClass , queueName ) { return this . queueTaskMap [ `${ queueClass }:${ queueName }` ] as Queue ; } }