summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/ChainedWorkflow.php
blob: ba9c8f969717cf9ed6eb5fbc78b2848c01561678 (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

declare(strict_types=1);

namespace Temporal\Tests\Workflow;

use Temporal\Activity\ActivityOptions;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;

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

        return yield Workflow::executeActivity(
            'SimpleActivity.echo',
            [$input],
            $opts
        )->then(function ($result) use ($opts) {
            return Workflow::executeActivity(
                'SimpleActivity.lower',
                ['Result:' . $result],
                $opts
            );
        });
    }
}