Skip to content

Commit

Permalink
add shouldCancel and shouldRun
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Sep 21, 2024
1 parent 2ea2bb1 commit a9870ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Models/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,18 @@ public function run(
if (
$this->isFinished() ||
$this->isFailed() ||
$this->isCanceled()
$this->isCanceled() ||
! $this->definition->shouldRun()
) {
return;
}

if ($this->definition->shouldCancel()) {
$this->markAsCanceled();

return;
}

$readySteps = $this->definition
->steps($this)
->filter(function ($step, $name) {
Expand Down
10 changes: 10 additions & 0 deletions src/WorkflowDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ public function start(): Workflow

return $workflow;
}

public function shouldCancel(): bool
{
return false;
}

public function shouldRun(): bool
{
return true;
}
}

0 comments on commit a9870ad

Please # to comment.