mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +00:00
refactor(core): Use an IoC container to manage singleton classes [Part-1] (no-changelog) (#5509)
* add typedi * convert ActiveWorkflowRunner into an injectable service * convert ExternalHooks into an injectable service * convert InternalHooks into an injectable service * convert LoadNodesAndCredentials into an injectable service * convert NodeTypes and CredentialTypes into an injectable service * convert ActiveExecutions into an injectable service * convert WaitTracker into an injectable service * convert Push into an injectable service * convert ActiveWebhooks and TestWebhooks into an injectable services * handle circular references, and log errors when a circular dependency is found
This commit is contained in:
committed by
GitHub
parent
aca94bb995
commit
52f740b9e8
@@ -2,8 +2,9 @@ import type Bull from 'bull';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
import type { IExecuteResponsePromiseData } from 'n8n-workflow';
|
||||
import config from '@/config';
|
||||
import * as ActiveExecutions from '@/ActiveExecutions';
|
||||
import { ActiveExecutions } from '@/ActiveExecutions';
|
||||
import * as WebhookHelpers from '@/WebhookHelpers';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
export type JobId = Bull.JobId;
|
||||
export type Job = Bull.Job<JobData>;
|
||||
@@ -26,7 +27,7 @@ export interface WebhookResponse {
|
||||
export class Queue {
|
||||
private jobQueue: JobQueue;
|
||||
|
||||
constructor(private activeExecutions: ActiveExecutions.ActiveExecutions) {}
|
||||
constructor(private activeExecutions: ActiveExecutions) {}
|
||||
|
||||
async init() {
|
||||
const prefix = config.getEnv('queue.bull.prefix');
|
||||
@@ -95,7 +96,7 @@ let activeQueueInstance: Queue | undefined;
|
||||
|
||||
export async function getInstance(): Promise<Queue> {
|
||||
if (activeQueueInstance === undefined) {
|
||||
activeQueueInstance = new Queue(ActiveExecutions.getInstance());
|
||||
activeQueueInstance = new Queue(Container.get(ActiveExecutions));
|
||||
await activeQueueInstance.init();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user