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

declare(strict_types=1);

namespace Temporal\Tests\Workflow;

use Temporal\Activity\ActivityOptions;
use Temporal\Common\RetryOptions;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
use Temporal\Tests\Activity\HeartBeatActivity;

#[Workflow\WorkflowInterface]
class FailedHeartbeatWorkflow
{
    #[WorkflowMethod(name: 'FailedHeartbeatWorkflow')]
    public function handler(
        int $iterations
    ): iterable {
        $act = Workflow::newActivityStub(
            HeartBeatActivity::class,
            ActivityOptions::new()
                ->withStartToCloseTimeout(50)
                // will fail on first attempt
                ->withRetryOptions(RetryOptions::new()->withMaximumAttempts(2))
        );

        return yield $act->failedActivity($iterations);
    }
}