import { Job , Queue } from 'bullmq' ; import { JobCleanStatus , JobCounts , JobStatus , QueueAdapterOptions } from '../../typings/app' ; import { BaseAdapter } from './base' ; export class BullMQAdapter extends BaseAdapter { private readonly LIMIT = 1000 ; constructor ( private queue , options = { } ) { super ( options ) ; } public async getRedisInfo ( ) { const client = await this . queue . client ; return client . info ( ) ; } public getName ( ) { return `${ this . prefix }${ this . queue . name }` ; } public clean ( jobStatus , graceTimeMs ) { return this . queue . clean ( graceTimeMs , this . LIMIT , jobStatus ) . then ( ( ) => undefined ) ; } public getJob ( id ) { return this . queue . getJob ( id ) ; } public getJobs ( jobStatuses , start ? , end ? ) { return this . queue . getJobs ( jobStatuses , start , end ) ; } public getJobCounts ( ... jobStatuses ) { return this . queue . getJobCounts ( ... jobStatuses ) as unknown as Promise < JobCounts > ; } public getJobLogs ( id ) { return this . queue . getJobLogs ( id ) . then ( ( { logs } ) => logs ) ; } public isPaused ( ) { return this . queue . isPaused ( ) ; } public pause ( ) { return this . queue . pause ( ) ; } public resume ( ) { return this . queue . resume ( ) ; } }