|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dtc\QueueBundle\Model; |
|
4
|
|
|
|
|
5
|
|
|
class Job extends BaseJob |
|
6
|
|
|
{ |
|
7
|
|
|
const STATUS_EXPIRED = 'expired'; |
|
8
|
|
|
|
|
9
|
|
|
protected $id; |
|
10
|
|
|
protected $message; |
|
11
|
|
|
protected $crcHash; |
|
12
|
|
|
protected $locked; |
|
13
|
|
|
protected $lockedAt; |
|
14
|
|
|
protected $expiresAt; |
|
15
|
|
|
protected $delay; |
|
16
|
|
|
protected $startedAt; |
|
17
|
|
|
protected $finishedAt; |
|
18
|
|
|
protected $maxDuration; |
|
19
|
|
|
protected $elapsed; |
|
20
|
|
|
protected $runId; |
|
21
|
|
|
|
|
22
|
63 |
|
public function __call($method, $args) |
|
23
|
|
|
{ |
|
24
|
63 |
|
$this->method = $method; |
|
25
|
63 |
|
$this->setArgs($args); |
|
26
|
|
|
|
|
27
|
|
|
// Make sure the method exists - job should not be created |
|
28
|
63 |
|
if (!method_exists($this->worker, $method)) { |
|
29
|
1 |
|
throw new \BadMethodCallException("{$this->className}->{$method}() does not exist"); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
63 |
|
$job = $this->jobManager->save($this); |
|
33
|
|
|
|
|
34
|
63 |
|
return $job; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return string|null |
|
39
|
|
|
*/ |
|
40
|
37 |
|
public function getMessage() |
|
41
|
|
|
{ |
|
42
|
37 |
|
return $this->message; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $message |
|
47
|
|
|
*/ |
|
48
|
19 |
|
public function setMessage($message) |
|
49
|
|
|
{ |
|
50
|
19 |
|
$this->message = $message; |
|
51
|
|
|
|
|
52
|
19 |
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return bool|null |
|
57
|
|
|
*/ |
|
58
|
36 |
|
public function getLocked() |
|
59
|
|
|
{ |
|
60
|
36 |
|
return $this->locked; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return \DateTime|null |
|
65
|
|
|
*/ |
|
66
|
36 |
|
public function getLockedAt() |
|
67
|
|
|
{ |
|
68
|
36 |
|
return $this->lockedAt; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return \DateTime|null |
|
73
|
|
|
*/ |
|
74
|
42 |
|
public function getExpiresAt() |
|
75
|
|
|
{ |
|
76
|
42 |
|
return $this->expiresAt; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param bool|null $locked |
|
81
|
|
|
*/ |
|
82
|
19 |
|
public function setLocked($locked) |
|
83
|
|
|
{ |
|
84
|
19 |
|
$this->locked = $locked; |
|
85
|
|
|
|
|
86
|
19 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param \DateTime|null $lockedAt |
|
91
|
|
|
*/ |
|
92
|
18 |
|
public function setLockedAt($lockedAt) |
|
93
|
|
|
{ |
|
94
|
18 |
|
$this->lockedAt = $lockedAt; |
|
95
|
|
|
|
|
96
|
18 |
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param \DateTime $expiresAt |
|
101
|
|
|
*/ |
|
102
|
6 |
|
public function setExpiresAt(\DateTime $expiresAt) |
|
103
|
|
|
{ |
|
104
|
6 |
|
$this->expiresAt = $expiresAt; |
|
105
|
|
|
|
|
106
|
6 |
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return int |
|
111
|
|
|
*/ |
|
112
|
70 |
|
public function getId() |
|
113
|
|
|
{ |
|
114
|
70 |
|
return $this->id; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return string |
|
119
|
|
|
*/ |
|
120
|
36 |
|
public function getCrcHash() |
|
121
|
|
|
{ |
|
122
|
36 |
|
return $this->crcHash; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @param mixed $id |
|
127
|
|
|
*/ |
|
128
|
61 |
|
public function setId($id) |
|
129
|
|
|
{ |
|
130
|
61 |
|
$this->id = $id; |
|
131
|
|
|
|
|
132
|
61 |
|
return $this; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @return \DateTime|null |
|
137
|
|
|
*/ |
|
138
|
29 |
|
public function getStartedAt() |
|
139
|
|
|
{ |
|
140
|
29 |
|
return $this->startedAt; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @param \DateTime|null $startedAt |
|
145
|
|
|
*/ |
|
146
|
8 |
|
public function setStartedAt(\DateTime $startedAt = null) |
|
147
|
|
|
{ |
|
148
|
8 |
|
$this->startedAt = $startedAt; |
|
149
|
|
|
|
|
150
|
8 |
|
return $this; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @return \DateTime|null |
|
155
|
|
|
*/ |
|
156
|
36 |
|
public function getFinishedAt() |
|
157
|
|
|
{ |
|
158
|
36 |
|
return $this->finishedAt; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @param \DateTime|null $finishedAt |
|
163
|
|
|
*/ |
|
164
|
17 |
|
public function setFinishedAt($finishedAt) |
|
165
|
|
|
{ |
|
166
|
17 |
|
$this->finishedAt = $finishedAt; |
|
167
|
|
|
|
|
168
|
17 |
|
return $this; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return int|null |
|
173
|
|
|
*/ |
|
174
|
36 |
|
public function getMaxDuration() |
|
175
|
|
|
{ |
|
176
|
36 |
|
return $this->maxDuration; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @param int|null $maxDuration |
|
181
|
|
|
*/ |
|
182
|
7 |
|
public function setMaxDuration($maxDuration) |
|
183
|
|
|
{ |
|
184
|
7 |
|
$this->maxDuration = $maxDuration; |
|
185
|
|
|
|
|
186
|
7 |
|
return $this; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @param string $crcHash |
|
191
|
|
|
*/ |
|
192
|
46 |
|
public function setCrcHash($crcHash) |
|
193
|
|
|
{ |
|
194
|
46 |
|
$this->crcHash = $crcHash; |
|
195
|
|
|
|
|
196
|
46 |
|
return $this; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @param JobManagerInterface $jobManager |
|
201
|
|
|
*/ |
|
202
|
29 |
|
public function setJobManager(JobManagerInterface $jobManager) |
|
203
|
|
|
{ |
|
204
|
29 |
|
$this->jobManager = $jobManager; |
|
205
|
|
|
|
|
206
|
29 |
|
return $this; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @return int |
|
211
|
|
|
*/ |
|
212
|
41 |
|
public function getDelay() |
|
213
|
|
|
{ |
|
214
|
41 |
|
return $this->delay; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @param int $delay Delay in seconds |
|
219
|
|
|
*/ |
|
220
|
23 |
|
public function setDelay($delay) |
|
221
|
|
|
{ |
|
222
|
23 |
|
$this->delay = $delay; |
|
223
|
|
|
|
|
224
|
23 |
|
return $this; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @return int |
|
229
|
|
|
*/ |
|
230
|
37 |
|
public function getElapsed() |
|
231
|
|
|
{ |
|
232
|
37 |
|
return $this->elapsed; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* @param int $elapsed |
|
237
|
|
|
*/ |
|
238
|
17 |
|
public function setElapsed($elapsed) |
|
239
|
|
|
{ |
|
240
|
17 |
|
$this->elapsed = $elapsed; |
|
241
|
|
|
|
|
242
|
17 |
|
return $this; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* @return mixed |
|
247
|
|
|
*/ |
|
248
|
20 |
|
public function getRunId() |
|
249
|
|
|
{ |
|
250
|
20 |
|
return $this->runId; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* @param mixed $runId |
|
255
|
|
|
*/ |
|
256
|
18 |
|
public function setRunId($runId) |
|
257
|
|
|
{ |
|
258
|
18 |
|
$this->runId = $runId; |
|
259
|
|
|
|
|
260
|
18 |
|
return $this; |
|
261
|
|
|
} |
|
262
|
|
|
} |
|
263
|
|
|
|