summaryrefslogtreecommitdiff
path: root/src/queue/index.ts
blob: 775e5f199db320733baaea7c55539af028518ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as Queue from 'bee-queue';

import config from '../config';
import http from './processors/http';
import { ILocalUser } from '../models/user';

const queue = new Queue('misskey', {
	redis: {
		port: config.redis.port,
		host: config.redis.host,
		password: config.redis.pass
	},

	removeOnSuccess: true,
	removeOnFailure: true,
	getEvents: false,
	sendEvents: false,
	storeJobs: false
});

export function createHttpJob(data: any) {
	return queue.createJob(data)
		//.retries(4)
		//.backoff('exponential', 16384) // 16s
		.save();
}

export function deliver(user: ILocalUser, content: any, to: any) {
	createHttpJob({
		type: 'deliver',
		user,
		content,
		to
	});
}

export default function() {
	queue.process(128, http);
}