1 | <?php |
||
10 | abstract class RetryableJobManager extends AbstractJobManager |
||
11 | { |
||
12 | protected $defaultMaxRetries; |
||
13 | protected $defaultMaxFailures; |
||
14 | protected $defaultMaxExceptions; |
||
15 | |||
16 | protected $autoRetryOnFailure; |
||
17 | protected $autoRetryOnException; |
||
18 | |||
19 | abstract protected function retryableSave(RetryableJob $job); |
||
20 | |||
21 | /** |
||
22 | * @param RetryableJob $job |
||
23 | * @param bool $retry bool |
||
24 | * |
||
25 | * @return |
||
26 | */ |
||
27 | abstract protected function retryableSaveHistory(RetryableJob $job, $retry); |
||
28 | |||
29 | 76 | public function save(Job $job) |
|
43 | |||
44 | /** |
||
45 | * @return bool true if retry |
||
46 | */ |
||
47 | 20 | public function saveHistory(Job $job) |
|
62 | |||
63 | 6 | private function updateJobException(RetryableJob $job) |
|
67 | |||
68 | /** |
||
69 | * @param string $type |
||
70 | * @param bool $autoRetry |
||
71 | */ |
||
72 | 17 | protected function updateJobMax(RetryableJob $job, $type, $maxStatus, $autoRetry) |
|
87 | |||
88 | 9 | private function updateJobFailure(RetryableJob $job) |
|
92 | |||
93 | /** |
||
94 | * Determine if we've hit a max retry condition. |
||
95 | * |
||
96 | * @param RetryableJob $job |
||
97 | * @param int $status |
||
98 | * @param int|null $max |
||
99 | * @param int $count |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | 19 | protected function updateMaxStatus(RetryableJob $job, $status, $max = null, $count = 0) |
|
113 | |||
114 | 14 | protected function resetRetryableJob(RetryableJob $job) |
|
124 | |||
125 | /** |
||
126 | * @param RetryableJob $job |
||
127 | * |
||
128 | * @return bool true if the job was successfully "reset", i.e. re-queued |
||
129 | */ |
||
130 | abstract protected function resetJob(RetryableJob $job); |
||
131 | |||
132 | 76 | protected function setBaseRetryableJobDefaults(RetryableJob $job) |
|
152 | |||
153 | /** |
||
154 | * @return int|null |
||
155 | */ |
||
156 | 6 | public function getDefaultMaxRetries() |
|
160 | |||
161 | /** |
||
162 | * @param int|null $defaultMaxRetries |
||
163 | */ |
||
164 | 6 | public function setDefaultMaxRetries($defaultMaxRetries) |
|
168 | |||
169 | /** |
||
170 | * @return int|null |
||
171 | */ |
||
172 | 6 | public function getDefaultMaxFailures() |
|
176 | |||
177 | /** |
||
178 | * @param int|null $defaultMaxFailures |
||
179 | */ |
||
180 | 6 | public function setDefaultMaxFailures($defaultMaxFailures) |
|
184 | |||
185 | /** |
||
186 | * @return bool |
||
187 | */ |
||
188 | 6 | public function getAutoRetryOnFailure() |
|
192 | |||
193 | /** |
||
194 | * @param bool $autoRetryOnFailure |
||
195 | */ |
||
196 | 18 | public function setAutoRetryOnFailure($autoRetryOnFailure) |
|
200 | |||
201 | /** |
||
202 | * @return bool |
||
203 | */ |
||
204 | 6 | public function getAutoRetryOnException() |
|
208 | |||
209 | /** |
||
210 | * @param bool $autoRetryOnException |
||
211 | */ |
||
212 | 12 | public function setAutoRetryOnException($autoRetryOnException) |
|
216 | |||
217 | /** |
||
218 | * @return int|null |
||
219 | */ |
||
220 | 6 | public function getDefaultMaxExceptions() |
|
224 | |||
225 | /** |
||
226 | * @param int|null $defaultMaxExceptions |
||
227 | */ |
||
228 | 6 | public function setDefaultMaxExceptions($defaultMaxExceptions) |
|
232 | |||
233 | 76 | protected function recordTiming(Job $job) |
|
242 | } |
||
243 |