mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
clean up
This commit is contained in:
parent
893eb5c42d
commit
2fde595611
|
@ -777,16 +777,48 @@ export async function executeWorkflow(
|
||||||
additionalData: IWorkflowExecuteAdditionalData,
|
additionalData: IWorkflowExecuteAdditionalData,
|
||||||
options: ExecuteWorkflowOptions,
|
options: ExecuteWorkflowOptions,
|
||||||
): Promise<ExecuteWorkflowData> {
|
): Promise<ExecuteWorkflowData> {
|
||||||
const externalHooks = Container.get(ExternalHooks);
|
|
||||||
await externalHooks.init();
|
|
||||||
|
|
||||||
const nodeTypes = Container.get(NodeTypes);
|
|
||||||
const activeExecutions = Container.get(ActiveExecutions);
|
const activeExecutions = Container.get(ActiveExecutions);
|
||||||
|
|
||||||
const workflowData =
|
const workflowData =
|
||||||
options.loadedWorkflowData ??
|
options.loadedWorkflowData ??
|
||||||
(await getWorkflowData(workflowInfo, options.parentWorkflowId, options.parentWorkflowSettings));
|
(await getWorkflowData(workflowInfo, options.parentWorkflowId, options.parentWorkflowSettings));
|
||||||
|
|
||||||
|
const runData =
|
||||||
|
options.loadedRunData ??
|
||||||
|
(await getRunData(workflowData, options.inputData, options.startMetadata));
|
||||||
|
|
||||||
|
const executionId = await activeExecutions.add(runData);
|
||||||
|
|
||||||
|
const executionPromise = startExecution(
|
||||||
|
additionalData,
|
||||||
|
options,
|
||||||
|
executionId,
|
||||||
|
runData,
|
||||||
|
workflowData,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (options.doNotWaitToFinish) {
|
||||||
|
return { executionId, data: [null] };
|
||||||
|
}
|
||||||
|
|
||||||
|
return await executionPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startExecution(
|
||||||
|
additionalData: IWorkflowExecuteAdditionalData,
|
||||||
|
options: ExecuteWorkflowOptions,
|
||||||
|
executionId: string,
|
||||||
|
runData: IWorkflowExecutionDataProcess,
|
||||||
|
workflowData: IWorkflowBase,
|
||||||
|
): Promise<ExecuteWorkflowData> {
|
||||||
|
const externalHooks = Container.get(ExternalHooks);
|
||||||
|
await externalHooks.init();
|
||||||
|
|
||||||
|
const nodeTypes = Container.get(NodeTypes);
|
||||||
|
const activeExecutions = Container.get(ActiveExecutions);
|
||||||
|
const eventService = Container.get(EventService);
|
||||||
|
const executionRepository = Container.get(ExecutionRepository);
|
||||||
|
|
||||||
const workflowName = workflowData ? workflowData.name : undefined;
|
const workflowName = workflowData ? workflowData.name : undefined;
|
||||||
const workflow = new Workflow({
|
const workflow = new Workflow({
|
||||||
id: workflowData.id,
|
id: workflowData.id,
|
||||||
|
@ -799,46 +831,6 @@ export async function executeWorkflow(
|
||||||
settings: workflowData.settings,
|
settings: workflowData.settings,
|
||||||
});
|
});
|
||||||
|
|
||||||
const runData =
|
|
||||||
options.loadedRunData ??
|
|
||||||
(await getRunData(workflowData, options.inputData, options.startMetadata));
|
|
||||||
|
|
||||||
const executionId = await activeExecutions.add(runData);
|
|
||||||
|
|
||||||
// We wrap it in another promise that we can depending on the setting return
|
|
||||||
// the execution ID before the execution is finished
|
|
||||||
const executionPromise = startExecution(
|
|
||||||
additionalData,
|
|
||||||
options,
|
|
||||||
workflow,
|
|
||||||
executionId,
|
|
||||||
runData,
|
|
||||||
workflowData,
|
|
||||||
externalHooks,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (options.doNotWaitToFinish) {
|
|
||||||
// todo check if not breaking change
|
|
||||||
return { executionId, data: [null] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return await executionPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo simplify
|
|
||||||
async function startExecution(
|
|
||||||
additionalData: IWorkflowExecuteAdditionalData,
|
|
||||||
options: ExecuteWorkflowOptions,
|
|
||||||
workflow: Workflow,
|
|
||||||
executionId: string,
|
|
||||||
runData: IWorkflowExecutionDataProcess,
|
|
||||||
workflowData: IWorkflowBase,
|
|
||||||
externalHooks: ExternalHooks,
|
|
||||||
): Promise<ExecuteWorkflowData> {
|
|
||||||
const eventService = Container.get(EventService);
|
|
||||||
const activeExecutions = Container.get(ActiveExecutions);
|
|
||||||
const executionRepository = Container.get(ExecutionRepository);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A subworkflow execution in queue mode is not enqueued, but rather runs in the
|
* A subworkflow execution in queue mode is not enqueued, but rather runs in the
|
||||||
* same worker process as the parent execution. Hence ensure the subworkflow
|
* same worker process as the parent execution. Hence ensure the subworkflow
|
||||||
|
|
Loading…
Reference in a new issue