blob: 576b126e595be5a8fc698d3fa615b3a27164489e (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
namespace Temporal\Tests\Activity;
use Temporal\Activity\ActivityInterface;
use Temporal\Activity\ActivityMethod;
use Temporal\Api\Common\V1\WorkflowExecution;
use Temporal\DataConverter\Bytes;
use Temporal\Tests\DTO\Message;
use Temporal\Tests\DTO\User;
#[ActivityInterface(prefix: "SimpleActivity.")]
class SimpleActivity
{
#[ActivityMethod]
public function echo(
string $input
): string {
return strtoupper($input);
}
#[ActivityMethod]
public function lower(
string $input
): string {
return strtolower($input);
}
#[ActivityMethod]
public function greet(
User $user
): Message {
return new Message(sprintf("Hello %s <%s>", $user->name, $user->email));
}
#[ActivityMethod]
public function slow(
string $input
): string {
sleep(2);
return strtolower($input);
}
#[ActivityMethod]
public function sha512(
Bytes $input
): string {
return hash("sha512", ($input->getData()));
}
public function updateRunID(WorkflowExecution $e): WorkflowExecution
{
$e->setRunId('updated');
return $e;
}
#[ActivityMethod]
public function fail()
{
throw new \Error("failed activity");
}
}
|