mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
feat(core): Offload manual executions to workers (#11284)
This commit is contained in:
@@ -5,7 +5,13 @@
|
||||
import type { PushMessage, PushType } from '@n8n/api-types';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { stringify } from 'flatted';
|
||||
import { ErrorReporter, Logger, WorkflowExecute, isObjectLiteral } from 'n8n-core';
|
||||
import {
|
||||
ErrorReporter,
|
||||
Logger,
|
||||
InstanceSettings,
|
||||
WorkflowExecute,
|
||||
isObjectLiteral,
|
||||
} from 'n8n-core';
|
||||
import { ApplicationError, NodeOperationError, Workflow, WorkflowHooks } from 'n8n-workflow';
|
||||
import type {
|
||||
IDataObject,
|
||||
@@ -1076,8 +1082,7 @@ function getWorkflowHooksIntegrated(
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns WorkflowHooks instance for running integrated workflows
|
||||
* (Workflows which get started inside of another workflow)
|
||||
* Returns WorkflowHooks instance for worker in scaling mode.
|
||||
*/
|
||||
export function getWorkflowHooksWorkerExecuter(
|
||||
mode: WorkflowExecuteMode,
|
||||
@@ -1093,6 +1098,17 @@ export function getWorkflowHooksWorkerExecuter(
|
||||
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
||||
}
|
||||
|
||||
if (mode === 'manual' && Container.get(InstanceSettings).isWorker) {
|
||||
const pushHooks = hookFunctionsPush();
|
||||
for (const key of Object.keys(pushHooks)) {
|
||||
if (hookFunctions[key] === undefined) {
|
||||
hookFunctions[key] = [];
|
||||
}
|
||||
// eslint-disable-next-line prefer-spread
|
||||
hookFunctions[key].push.apply(hookFunctions[key], pushHooks[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user