-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathQueryWorkflow.php
More file actions
37 lines (28 loc) · 936 Bytes
/
QueryWorkflow.php
File metadata and controls
37 lines (28 loc) · 936 Bytes
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
<?php
/**
* This file is part of Temporal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Temporal\Samples\Query;
use Carbon\CarbonInterval;
use Temporal\Activity\ActivityOptions;
use Temporal\Workflow;
/** Demonstrates query capability. Requires a local instance of Temporal server to be running. */
class QueryWorkflow implements QueryWorkflowInterface
{
private string $message = '';
public function createGreeting(string $name)
{
$this->message = sprintf('Hello, %s!', $name);
// Always use Workflow::timer() instead of native sleep() and usleep() functions
yield Workflow::timer(CarbonInterval::seconds(2));
$this->message = sprintf('Bye, %s!', $name);
}
public function queryGreeting(): string
{
return $this->message;
}
}