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