iceshrimp-161sh/src/queue/initialize.ts

19 lines
467 B
TypeScript
Raw Normal View History

2021-05-08 11:56:21 +02:00
import * as Bull from 'bull';
import config from '@/config/index.js';
2021-05-08 11:56:21 +02:00
export function initialize<T>(name: string, limitPerSec = -1) {
return new Bull<T>(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
});
}