-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathExecuteCommand.php
More file actions
57 lines (46 loc) · 2.04 KB
/
ExecuteCommand.php
File metadata and controls
57 lines (46 loc) · 2.04 KB
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
<?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\FileProcessing;
use Carbon\CarbonInterval;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Temporal\Client\WorkflowOptions;
use Temporal\Samples\Exception\FailedWorkflow;
use Temporal\SampleUtils\Command;
class ExecuteCommand extends Command
{
protected const NAME = 'process-file';
protected const DESCRIPTION = 'Execute FileProcessing\FileProcessingWorkflow with local task queue routing';
protected const ARGUMENTS = [
['url', InputArgument::REQUIRED, 'Download URL']
];
public function execute(InputInterface $input, OutputInterface $output): int
{
$workflow = $this->workflowClient->newWorkflowStub(
FileProcessingWorkflowInterface::class,
WorkflowOptions::new()->withWorkflowExecutionTimeout(CarbonInterval::minute(10))
);
$output->writeln("Starting <comment>FileProcessing</comment>... ");
// This is going to block until the workflow completes.
// This is rarely used in production. Use the commented code below for async start version.
$result = $workflow->processFile($input->getArgument('url'), 'targetURL');
$output->writeln(sprintf("Result:\n<info>%s</info>", print_r($result, true)));
//$run = $this->workflowClient->start($workflow, $input->getArgument('url'), 'targetURL');
//$output->writeln(
// sprintf(
// 'Started: WorkflowID=<fg=magenta>%s</fg=magenta>, RunID=<fg=magenta>%s</fg=magenta>',
// $run->getExecution()->getID(),
// $run->getExecution()->getRunID(),
// )
//);
//$output->writeln(sprintf("Result:\n<info>%s</info>", print_r($run->getResult(), true)));
return self::SUCCESS;
}
}