{"size": 934, "ext": "js", "max_stars_repo_path": "src/controllers/asyncquery_queue.js", "max_stars_repo_name": "newgene/BioThings_Explorer_TRAPI", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/controllers/asyncquery_queue.js", "max_issues_repo_name": "newgene/BioThings_Explorer_TRAPI", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/controllers/asyncquery_queue.js", "max_forks_repo_name": "newgene/BioThings_Explorer_TRAPI", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.2068965517, "max_line_length": 84, "alphanum_fraction": 0.5192719486}
const Queue = require('bull');
const redisClient = require('../utils/cache/redis-client');

exports.getQueryQueue = (name) => {
    let queryQueue = null;
    if(Object.keys(redisClient).length !== 0){
        let details = { port: process.env.REDIS_PORT, host: process.env.REDIS_HOST }
        if( process.env.REDIS_PASSWORD) {
            details.password = process.env.REDIS_PASSWORD
        }
        queryQueue = new Queue(name, process.env.REDIS_HOST ?
            { redis: details } : 'redis://127.0.0.1:6379',
            {
                defaultJobOptions: {
                    timeout: process.env.JOB_TIMEOUT,
                    removeOnFail: true
                },
                settings: {
                    maxStalledCount: 1,
                    lockDuration: 300000
                }
            }).on('error', function (error){
            console.log('err', error)
        });
    }
    return queryQueue
}

