2021-03-18 03:17:05 +01:00
|
|
|
import * as Queue from 'bull';
|
2021-03-23 09:43:07 +01:00
|
|
|
import config from '@/config';
|
2021-03-18 03:17:05 +01:00
|
|
|
|
|
|
|
export function initialize(name: string, limitPerSec = -1) {
|
|
|
|
return new Queue(name, {
|
|
|
|
redis: {
|
|
|
|
port: config.redis.port,
|
|
|
|
host: config.redis.host,
|
|
|
|
password: config.redis.pass,
|
|
|
|
db: config.redis.db || 0,
|
|
|
|
},
|
|
|
|
prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue',
|
|
|
|
limiter: limitPerSec > 0 ? {
|
|
|
|
max: limitPerSec * 5,
|
|
|
|
duration: 5000
|
|
|
|
} : undefined
|
|
|
|
});
|
|
|
|
}
|