refactor: Extract processor job into separate background jobs
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import Context from '../../types/express/context';
|
||||
import Processor from '../../services/processor';
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import processorQueue from '../../queues/processor';
|
||||
import flowQueue from '../../queues/flow';
|
||||
|
||||
type Params = {
|
||||
input: {
|
||||
@@ -14,30 +13,25 @@ const executeFlow = async (
|
||||
params: Params,
|
||||
context: Context
|
||||
) => {
|
||||
const untilStep = await context.currentUser
|
||||
.$relatedQuery('steps')
|
||||
.withGraphFetched('connection')
|
||||
.findOne({
|
||||
'steps.id': params.input.stepId,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
const flow = await untilStep.$relatedQuery('flow');
|
||||
|
||||
const executionStep = await new Processor(flow, {
|
||||
untilStep,
|
||||
testRun: true,
|
||||
}).run();
|
||||
|
||||
await untilStep.$query().patch({
|
||||
status: 'completed',
|
||||
});
|
||||
|
||||
if (executionStep.errorDetails) {
|
||||
throw new Error(JSON.stringify(executionStep.errorDetails));
|
||||
}
|
||||
|
||||
return { data: executionStep.dataOut, step: untilStep };
|
||||
// const untilStep = await context.currentUser
|
||||
// .$relatedQuery('steps')
|
||||
// .withGraphFetched('connection')
|
||||
// .findOne({
|
||||
// 'steps.id': params.input.stepId,
|
||||
// })
|
||||
// .throwIfNotFound();
|
||||
// const flow = await untilStep.$relatedQuery('flow');
|
||||
// const executionStep = await new Processor(flow, {
|
||||
// untilStep,
|
||||
// testRun: true,
|
||||
// }).run();
|
||||
// await untilStep.$query().patch({
|
||||
// status: 'completed',
|
||||
// });
|
||||
// if (executionStep.errorDetails) {
|
||||
// throw new Error(JSON.stringify(executionStep.errorDetails));
|
||||
// }
|
||||
// return { data: executionStep.dataOut, step: untilStep };
|
||||
};
|
||||
|
||||
export default executeFlow;
|
||||
|
Reference in New Issue
Block a user