summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue/RelationshipQueueProcessorsService.ts
blob: af086fa4e74dc86422d0a5b8ff2fb468379eaf05 (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
import { Inject, Injectable } from '@nestjs/common';
import { bindThis } from '@/decorators.js';
import { RelationshipProcessorService } from './processors/RelationshipProcessorService.js';
import type Bull from 'bull';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';

@Injectable()
export class RelationshipQueueProcessorsService {
	constructor(
		@Inject(DI.config)
		private config: Config,

		private relationshipProcessorService: RelationshipProcessorService,
	) {
	}

	@bindThis
	public start(q: Bull.Queue): void {
		const maxJobs = (this.config.deliverJobConcurrency ?? 128) / 4; // conservative?
		q.process('follow', maxJobs, (job) => this.relationshipProcessorService.processFollow(job));
		q.process('unfollow', maxJobs, (job) => this.relationshipProcessorService.processUnfollow(job));
		q.process('block', maxJobs, (job) => this.relationshipProcessorService.processBlock(job));
		q.process('unblock', maxJobs, (job) => this.relationshipProcessorService.processUnblock(job));
	}
}