Add "core" automation integration & implement wait action

The "core" integration will provide triggers, actions, and subjects
that are not specific to any 3rd party integration.

[MAILPOET-4136]
This commit is contained in:
Jan Jakes
2022-03-07 16:08:07 +01:00
committed by Veljko V
parent f7866aab49
commit fc16bacadc
6 changed files with 95 additions and 11 deletions

View File

@@ -82,6 +82,12 @@ class StepRunner {
throw Exceptions::workflowNotFound($workflowRun->getWorkflowId());
}
// complete workflow run
if (!$stepId) {
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
return;
}
$step = $workflow->getStep($stepId);
if (!$step) {
throw Exceptions::workflowStepNotFound($stepId);
@@ -94,19 +100,21 @@ class StepRunner {
throw new InvalidStateException();
}
// enqueue next step / complete workflow
$nextStepId = $step->getNextStepId();
if ($nextStepId) {
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, [
[
'workflow_run_id' => $workflowRunId,
'step_id' => $nextStepId,
],
]);
} else {
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
$nextStepArgs = [
[
'workflow_run_id' => $workflowRunId,
'step_id' => $step->getNextStepId(),
],
];
// next step scheduled by action
if ($this->actionScheduler->hasScheduledAction(Hooks::WORKFLOW_STEP, $nextStepArgs)) {
return;
}
// enqueue next step
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, $nextStepArgs);
// TODO: allow long-running steps (that are not done here yet)
}
}