blob: 50e0992facf50c0abc538d488f87d47364fb0d44 (
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
32
33
34
35
36
37
38
39
|
<?php
namespace Temporal\Tests\Workflow;
use Temporal\Activity\ActivityOptions;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Tests\Activity\SimpleActivity;
#[Workflow\WorkflowInterface]
class CancelledScopeWorkflow
{
#[WorkflowMethod(name: 'CancelledScopeWorkflow')]
public function handler()
{
$simple = Workflow::newActivityStub(
SimpleActivity::class,
ActivityOptions::new()->withStartToCloseTimeout(5)
);
$cancelled = 'not';
$scope = Workflow::newCancellationScope(
function () use ($simple) {
yield Workflow::timer(2);
yield $simple->slow('hello');
}
)->onCancel(
function () use (&$cancelled) {
$cancelled = 'yes';
}
);
yield Workflow::timer(1);
$scope->cancel();
return $cancelled;
}
}
|