-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathTestSignalExceptionWorkflow.php
More file actions
38 lines (32 loc) · 912 Bytes
/
TestSignalExceptionWorkflow.php
File metadata and controls
38 lines (32 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Tests\Fixtures;
use Throwable;
use Workflow\ActivityStub;
use Workflow\SignalMethod;
use Workflow\Workflow;
use Workflow\WorkflowStub;
class TestSignalExceptionWorkflow extends Workflow
{
protected bool $shouldRetry = false;
#[SignalMethod]
public function shouldRetry(): void
{
$this->shouldRetry = true;
}
public function execute(array $data = [])
{
$shouldThrow = true;
while (true) {
try {
yield ActivityStub::make(TestActivity::class);
yield ActivityStub::make(TestSingleTryExceptionActivity::class, $shouldThrow);
return true;
} catch (Throwable) {
yield WorkflowStub::await(fn () => $this->shouldRetry);
$this->shouldRetry = false;
$shouldThrow = false;
}
}
}
}