1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Gearman Bundle for Symfony2 / Symfony3 |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* Feel free to edit as you please, and have fun. |
10
|
|
|
* |
11
|
|
|
* @author Marc Morera <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Mkk\GearmanBundle\Command; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
use Mkk\GearmanBundle\Command\Abstracts\AbstractGearmanCommand; |
20
|
|
|
use Mkk\GearmanBundle\Service\GearmanClient; |
21
|
|
|
use Mkk\GearmanBundle\Service\GearmanDescriber; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Gearman Job Describe Command class |
25
|
|
|
*/ |
26
|
|
|
class GearmanWorkerDescribeCommand extends AbstractGearmanCommand |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var GearmanClient |
30
|
|
|
* |
31
|
|
|
* Gearman client |
32
|
|
|
*/ |
33
|
|
|
protected $gearmanClient; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var GearmanDescriber |
37
|
|
|
* |
38
|
|
|
* GearmanDescriber |
39
|
|
|
*/ |
40
|
|
|
protected $gearmanDescriber; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Set gearman client |
44
|
|
|
* |
45
|
|
|
* @param GearmanClient $gearmanClient Gearman client |
46
|
|
|
* |
47
|
|
|
* @return GearmanWorkerDescribeCommand self Object |
48
|
|
|
*/ |
49
|
1 |
|
public function setGearmanClient(GearmanClient $gearmanClient) |
50
|
|
|
{ |
51
|
1 |
|
$this->gearmanClient = $gearmanClient; |
52
|
|
|
|
53
|
1 |
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* set Gearman describer |
58
|
|
|
* |
59
|
|
|
* @param GearmanDescriber $gearmanDescriber GearmanDescriber |
60
|
|
|
* |
61
|
|
|
* @return GearmanWorkerDescribeCommand self Object |
62
|
|
|
*/ |
63
|
1 |
|
public function setGearmanDescriber(GearmanDescriber $gearmanDescriber) |
64
|
|
|
{ |
65
|
1 |
|
$this->gearmanDescriber = $gearmanDescriber; |
66
|
|
|
|
67
|
1 |
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Console Command configuration |
72
|
|
|
*/ |
73
|
1 |
|
protected function configure() |
74
|
|
|
{ |
75
|
1 |
|
parent::configure(); |
76
|
|
|
|
77
|
|
|
$this |
78
|
1 |
|
->setName('gearman:worker:describe') |
79
|
1 |
|
->setDescription('Describe given worker') |
80
|
1 |
|
->addArgument( |
81
|
1 |
|
'worker', |
82
|
1 |
|
InputArgument::REQUIRED, |
83
|
1 |
|
'worker to describe' |
84
|
|
|
); |
85
|
1 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Executes the current command. |
89
|
|
|
* |
90
|
|
|
* @param InputInterface $input An InputInterface instance |
91
|
|
|
* @param OutputInterface $output An OutputInterface instance |
92
|
|
|
* |
93
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
|
|
|
94
|
|
|
* |
95
|
|
|
* @throws \LogicException When this abstract class is not implemented |
96
|
|
|
*/ |
97
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
98
|
|
|
{ |
99
|
1 |
|
$worker = $input->getArgument('worker'); |
100
|
|
|
$worker = $this |
101
|
1 |
|
->gearmanClient |
102
|
1 |
|
->getWorker($worker); |
103
|
|
|
|
104
|
|
|
$this |
105
|
1 |
|
->gearmanDescriber |
106
|
1 |
|
->describeWorker( |
107
|
|
|
$output, |
108
|
|
|
$worker |
109
|
|
|
); |
110
|
1 |
|
} |
111
|
|
|
} |
|
|
|
|
112
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.