1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pheanstalk\Structure; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* A job in a EvQueue server. |
7
|
|
|
* |
8
|
|
|
* @author Valentin Corre |
9
|
|
|
* @package Pheanstalk |
10
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php |
11
|
|
|
*/ |
12
|
|
|
class TaskInstance extends Task |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** @var int $contextId */ |
16
|
|
|
protected $contextId; |
17
|
|
|
|
18
|
|
|
/** @var int $evqid */ |
19
|
|
|
protected $evqid; |
20
|
|
|
|
21
|
|
|
/** @var \DateTime $execution_time */ |
22
|
|
|
protected $execution_time; |
23
|
|
|
|
24
|
|
|
/** @var int $pid */ |
25
|
|
|
protected $pid; |
26
|
|
|
|
27
|
|
|
/** @var int $progression */ |
28
|
|
|
protected $progression; |
29
|
|
|
|
30
|
|
|
/** @var string $status */ |
31
|
|
|
protected $status; |
32
|
|
|
|
33
|
|
|
/** @var int $tid */ |
34
|
|
|
protected $tid; |
35
|
|
|
|
36
|
15 |
|
public function __construct(array $params) |
37
|
|
|
{ |
38
|
15 |
|
$this->fillWithSnakeParams($params, '-'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return int |
43
|
|
|
*/ |
44
|
1 |
|
public function getContextId(): int |
45
|
|
|
{ |
46
|
1 |
|
return $this->contextId; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param int $contextId |
51
|
|
|
* |
52
|
|
|
* @return TaskInstance |
53
|
|
|
*/ |
54
|
1 |
|
public function setContextId(int $contextId): TaskInstance |
55
|
|
|
{ |
56
|
1 |
|
$this->contextId = $contextId; |
57
|
1 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return int |
62
|
|
|
*/ |
63
|
1 |
|
public function getEvqid(): int |
64
|
|
|
{ |
65
|
1 |
|
return $this->evqid; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param int $evqid |
70
|
|
|
* |
71
|
|
|
* @return TaskInstance |
72
|
|
|
*/ |
73
|
1 |
|
public function setEvqid(int $evqid): TaskInstance |
74
|
|
|
{ |
75
|
1 |
|
$this->evqid = $evqid; |
76
|
1 |
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return \DateTime |
81
|
|
|
*/ |
82
|
1 |
|
public function getExecutionTime(): \DateTime |
83
|
|
|
{ |
84
|
1 |
|
return $this->execution_time; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param \DateTime $execution_time |
89
|
|
|
* |
90
|
|
|
* @return TaskInstance |
91
|
|
|
*/ |
92
|
1 |
|
public function setExecutionTime(\DateTime $execution_time): TaskInstance |
93
|
|
|
{ |
94
|
1 |
|
$this->execution_time = $execution_time; |
95
|
1 |
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return int |
100
|
|
|
*/ |
101
|
2 |
|
public function getPid(): int |
102
|
|
|
{ |
103
|
2 |
|
return $this->pid; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param int $pid |
108
|
|
|
* |
109
|
|
|
* @return TaskInstance |
110
|
|
|
*/ |
111
|
1 |
|
public function setPid(int $pid): TaskInstance |
112
|
|
|
{ |
113
|
1 |
|
$this->pid = $pid; |
114
|
1 |
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return int |
119
|
|
|
*/ |
120
|
1 |
|
public function getProgression(): int |
121
|
|
|
{ |
122
|
1 |
|
return $this->progression; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param int $progression |
127
|
|
|
* |
128
|
|
|
* @return TaskInstance |
129
|
|
|
*/ |
130
|
1 |
|
public function setProgression(int $progression): TaskInstance |
131
|
|
|
{ |
132
|
1 |
|
$this->progression = $progression; |
133
|
1 |
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
1 |
|
public function getStatus(): string |
140
|
|
|
{ |
141
|
1 |
|
return $this->status; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $status |
146
|
|
|
* |
147
|
|
|
* @return TaskInstance |
148
|
|
|
*/ |
149
|
1 |
|
public function setStatus(string $status): TaskInstance |
150
|
|
|
{ |
151
|
1 |
|
$this->status = $status; |
152
|
1 |
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return int |
157
|
|
|
*/ |
158
|
1 |
|
public function getTid(): int |
159
|
|
|
{ |
160
|
1 |
|
return $this->tid; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param int $tid |
165
|
|
|
* |
166
|
|
|
* @return TaskInstance |
167
|
|
|
*/ |
168
|
1 |
|
public function setTid(int $tid): TaskInstance |
169
|
|
|
{ |
170
|
1 |
|
$this->tid = $tid; |
171
|
1 |
|
return $this; |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|