2022-09-17 21:27:08 +03:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2022-09-20 23:33:11 +03:00
|
|
|
import type { Config } from '@/config.js';
|
2022-09-17 21:27:08 +03:00
|
|
|
import { CleanRemoteFilesProcessorService } from './processors/CleanRemoteFilesProcessorService.js';
|
|
|
|
import { DeleteFileProcessorService } from './processors/DeleteFileProcessorService.js';
|
|
|
|
import type Bull from 'bull';
|
2022-12-04 08:03:09 +02:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2022-09-17 21:27:08 +03:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ObjectStorageQueueProcessorsService {
|
|
|
|
constructor(
|
|
|
|
@Inject(DI.config)
|
|
|
|
private config: Config,
|
|
|
|
|
|
|
|
private deleteFileProcessorService: DeleteFileProcessorService,
|
|
|
|
private cleanRemoteFilesProcessorService: CleanRemoteFilesProcessorService,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-24 08:45:44 +03:00
|
|
|
public start(q: Bull.Queue): void {
|
|
|
|
q.process('deleteFile', 16, (job) => this.deleteFileProcessorService.process(job));
|
|
|
|
q.process('cleanRemoteFiles', 16, (job, done) => this.cleanRemoteFilesProcessorService.process(job, done));
|
2022-09-17 21:27:08 +03:00
|
|
|
}
|
|
|
|
}
|