mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +00:00
perf: Lazy-load queue-mode and analytics dependencies (#5061)
* refactor: lazy load ioredis and bull * upgrade bull and hiredis * refactor: lazy load posthog, rudderstack, and sentry * upgrade Sentry sdk
This commit is contained in:
committed by
GitHub
parent
7e3f3c5097
commit
b828cb31d6
@@ -1,4 +1,5 @@
|
||||
import Bull from 'bull';
|
||||
import type Bull from 'bull';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
import { IExecuteResponsePromiseData } from 'n8n-workflow';
|
||||
import config from '@/config';
|
||||
import * as ActiveExecutions from '@/ActiveExecutions';
|
||||
@@ -22,15 +23,17 @@ export interface WebhookResponse {
|
||||
}
|
||||
|
||||
export class Queue {
|
||||
private activeExecutions: ActiveExecutions.ActiveExecutions;
|
||||
|
||||
private jobQueue: JobQueue;
|
||||
|
||||
constructor() {
|
||||
this.activeExecutions = ActiveExecutions.getInstance();
|
||||
constructor(private activeExecutions: ActiveExecutions.ActiveExecutions) {}
|
||||
|
||||
async init() {
|
||||
const prefix = config.getEnv('queue.bull.prefix');
|
||||
const redisOptions = config.getEnv('queue.bull.redis');
|
||||
const redisOptions: RedisOptions = config.getEnv('queue.bull.redis');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const { default: Bull } = await import('bull');
|
||||
|
||||
// Disabling ready check is necessary as it allows worker to
|
||||
// quickly reconnect to Redis if Redis crashes or is unreachable
|
||||
// for some time. With it enabled, worker might take minutes to realize
|
||||
@@ -89,9 +92,10 @@ export class Queue {
|
||||
|
||||
let activeQueueInstance: Queue | undefined;
|
||||
|
||||
export function getInstance(): Queue {
|
||||
export async function getInstance(): Promise<Queue> {
|
||||
if (activeQueueInstance === undefined) {
|
||||
activeQueueInstance = new Queue();
|
||||
activeQueueInstance = new Queue(ActiveExecutions.getInstance());
|
||||
await activeQueueInstance.init();
|
||||
}
|
||||
|
||||
return activeQueueInstance;
|
||||
|
||||
Reference in New Issue
Block a user