Improve typing on Queue and Jobs (#3892)

also, move all things related to `bull` into a single place.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-09-09 15:14:49 +02:00
committed by GitHub
parent 12507d39d6
commit f5c6c21bf4
4 changed files with 47 additions and 56 deletions

View File

@@ -31,17 +31,13 @@ import PCancelable from 'p-cancelable';
import { join as pathJoin } from 'path';
import { fork } from 'child_process';
import Bull from 'bull';
import config from '../config';
// eslint-disable-next-line import/no-cycle
import {
ActiveExecutions,
CredentialsOverwrites,
CredentialTypes,
Db,
ExternalHooks,
IBullJobData,
IBullJobResponse,
ICredentialsOverwrite,
ICredentialsTypeData,
IExecutionFlattedDb,
@@ -67,7 +63,7 @@ export class WorkflowRunner {
push: Push.Push;
jobQueue: Bull.Queue;
jobQueue: Queue.JobQueue;
constructor() {
this.push = Push.getInstance();
@@ -387,7 +383,7 @@ export class WorkflowRunner {
this.activeExecutions.attachResponsePromise(executionId, responsePromise);
}
const jobData: IBullJobData = {
const jobData: Queue.JobData = {
executionId,
loadStaticData: !!loadStaticData,
};
@@ -404,7 +400,7 @@ export class WorkflowRunner {
removeOnComplete: true,
removeOnFail: true,
};
let job: Bull.Job;
let job: Queue.Job;
let hooks: WorkflowHooks;
try {
job = await this.jobQueue.add(jobData, jobOptions);
@@ -455,11 +451,11 @@ export class WorkflowRunner {
reject(error);
});
const jobData: Promise<IBullJobResponse> = job.finished();
const jobData: Promise<Queue.JobResponse> = job.finished();
const queueRecoveryInterval = config.getEnv('queue.bull.queueRecoveryInterval');
const racingPromises: Array<Promise<IBullJobResponse | object>> = [jobData];
const racingPromises: Array<Promise<Queue.JobResponse | object>> = [jobData];
let clearWatchdogInterval;
if (queueRecoveryInterval > 0) {