summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/SideEffectWorkflow.php
blob: 95d396e401cf20fa649dbd770d32f160c4f9d0c0 (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
<?php

namespace Temporal\Tests\Workflow;

use Temporal\Activity\ActivityOptions;
use Temporal\Common\Uuid;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Tests\Activity\SimpleActivity;

#[Workflow\WorkflowInterface]
class SideEffectWorkflow
{
    #[WorkflowMethod(name: 'SideEffectWorkflow')]
    public function handler(string $input): iterable
    {
        $simple = Workflow::newActivityStub(
            SimpleActivity::class,
            ActivityOptions::new()->withStartToCloseTimeout(5)
        );

        $result = yield Workflow::sideEffect(
            function () use ($input) {
                return $input . '-42';
            }
        );

        return yield $simple->lower($result);
    }
}