blob: be9f7542eb7b8a269f7cece10553b7de8ecbf48b (
plain)
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
|
<?php
namespace Temporal\Tests\Workflow;
use Temporal\Activity\ActivityOptions;
use Temporal\Exception\Failure\CanceledFailure;
use Temporal\Tests\Activity\SimpleActivity;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
#[Workflow\WorkflowInterface]
class CancelledWorkflow
{
#[WorkflowMethod(name: 'CancelledWorkflow')]
public function handler()
{
$simple = Workflow::newActivityStub(
SimpleActivity::class,
ActivityOptions::new()->withStartToCloseTimeout(5)
);
// waits for 2 seconds
$slow = $simple->slow('DOING SLOW ACTIVITY');
try {
return yield $slow;
} catch (CanceledFailure $e) {
return "CANCELLED";
}
}
}
|