fix(worker): compute parameters for delaying job
This commit is contained in:
@@ -4,18 +4,18 @@ import delayForAsMilliseconds, {
|
|||||||
} from './delay-for-as-milliseconds';
|
} from './delay-for-as-milliseconds';
|
||||||
import delayUntilAsMilliseconds from './delay-until-as-milliseconds';
|
import delayUntilAsMilliseconds from './delay-until-as-milliseconds';
|
||||||
|
|
||||||
const delayAsMilliseconds = (step: Step) => {
|
const delayAsMilliseconds = (eventKey: Step["key"], computedParameters: Step["parameters"]) => {
|
||||||
let delayDuration = 0;
|
let delayDuration = 0;
|
||||||
|
|
||||||
if (step.key === 'delayFor') {
|
if (eventKey === 'delayFor') {
|
||||||
const { delayForUnit, delayForValue } = step.parameters;
|
const { delayForUnit, delayForValue } = computedParameters;
|
||||||
|
|
||||||
delayDuration = delayForAsMilliseconds(
|
delayDuration = delayForAsMilliseconds(
|
||||||
delayForUnit as TDelayForUnit,
|
delayForUnit as TDelayForUnit,
|
||||||
Number(delayForValue)
|
Number(delayForValue)
|
||||||
);
|
);
|
||||||
} else if (step.key === 'delayUntil') {
|
} else if (eventKey === 'delayUntil') {
|
||||||
const { delayUntil } = step.parameters;
|
const { delayUntil } = computedParameters;
|
||||||
delayDuration = delayUntilAsMilliseconds(delayUntil as string);
|
delayDuration = delayUntilAsMilliseconds(delayUntil as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,5 +65,5 @@ export const processAction = async (options: ProcessActionOptions) => {
|
|||||||
errorDetails: $.actionOutput.error ? $.actionOutput.error : null,
|
errorDetails: $.actionOutput.error ? $.actionOutput.error : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { flowId, stepId, executionId, executionStep };
|
return { flowId, stepId, executionId, executionStep, computedParameters };
|
||||||
};
|
};
|
||||||
|
@@ -21,7 +21,7 @@ const DEFAULT_DELAY_DURATION = 0;
|
|||||||
export const worker = new Worker(
|
export const worker = new Worker(
|
||||||
'action',
|
'action',
|
||||||
async (job) => {
|
async (job) => {
|
||||||
const { stepId, flowId, executionId } = await processAction(
|
const { stepId, flowId, executionId, computedParameters } = await processAction(
|
||||||
job.data as JobData
|
job.data as JobData
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ export const worker = new Worker(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (step.appKey === 'delay') {
|
if (step.appKey === 'delay') {
|
||||||
jobOptions.delay = delayAsMilliseconds(step);
|
jobOptions.delay = delayAsMilliseconds(step.key, computedParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
await actionQueue.add(jobName, jobPayload, jobOptions);
|
await actionQueue.add(jobName, jobPayload, jobOptions);
|
||||||
|
Reference in New Issue
Block a user