|
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\Event; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\EventDispatcher\Event; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* GearmanWorkExecutedEvent |
|
20
|
|
|
* |
|
21
|
|
|
* @author Dominic Grostate <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class GearmanWorkExecutedEvent extends Event |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var array |
|
27
|
|
|
* |
|
28
|
|
|
* Gearman jobs running |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $jobs; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var int |
|
34
|
|
|
* |
|
35
|
|
|
* Remaining iterations on work |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $iterationsRemaining; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var int |
|
41
|
|
|
* |
|
42
|
|
|
* Return code from last ran job |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $returnCode; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Construct method |
|
48
|
|
|
* |
|
49
|
|
|
* @param array $jobs Jobs |
|
50
|
|
|
* @param int $iterationsRemaining Iterations Remaining |
|
51
|
|
|
* @param int $returnCode Return code |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function __construct(array $jobs, $iterationsRemaining, $returnCode) |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->jobs = $jobs; |
|
56
|
1 |
|
$this->iterationsRemaining = $iterationsRemaining; |
|
57
|
1 |
|
$this->returnCode = $returnCode; |
|
58
|
1 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get Gearman Work subscribed jobs |
|
62
|
|
|
* |
|
63
|
|
|
* @return array Subscribed jobs |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getJobs() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->jobs; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Get Gearman Work remaining iteration length |
|
72
|
|
|
* |
|
73
|
|
|
* @return int Remaining iterations |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getIterationsRemaining() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->iterationsRemaining; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Get Gearman Job return code |
|
82
|
|
|
* |
|
83
|
|
|
* @return int Last return code |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getReturnCode() |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->returnCode; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|