summaryrefslogtreecommitdiff
path: root/src/queue/initialize.ts
blob: 4c0e5f9d87337a9b34405a90d9fda1c5c6c88d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import * as Bull from 'bull';
import config from '@/config';

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
	});
}