All files / redis-smq-monitor/src/lib queue-manager.ts

100% Statements 12/12
100% Branches 2/2
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2157x   57x   57x 57x   57x 38x 33x   38x     57x 33x 33x 33x      
import { QueueManager } from 'redis-smq';
import { TConfig } from '../../types';
import { promisifyAll } from 'bluebird';
 
const QueueManagerAsync = promisifyAll(QueueManager);
let queueManager: QueueManager | null = null;
 
export async function getQueueManagerInstance(config: TConfig) {
  if (!queueManager) {
    queueManager = await QueueManagerAsync.createInstanceAsync(config);
  }
  return queueManager;
}
 
export async function destroyQueueManager() {
  if (queueManager) {
    await promisifyAll(queueManager).quitAsync();
    queueManager = null;
  }
}