1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Redis backend for storing failed Resque jobs. |
||
5 | * |
||
6 | * @package Resque/Failure |
||
7 | * @author Chris Boulton <[email protected]> |
||
8 | * @license http://www.opensource.org/licenses/mit-license.php |
||
9 | */ |
||
10 | |||
11 | class Resque_Failure_Redis implements Resque_Failure_Interface |
||
12 | { |
||
13 | /** |
||
14 | * Initialize a failed job class and save it (where appropriate). |
||
15 | * |
||
16 | * @param object $payload Object containing details of the failed job. |
||
17 | * @param object $exception Instance of the exception that was thrown by the failed job. |
||
18 | * @param object $worker Instance of Resque_Worker that received the job. |
||
19 | * @param string $queue The name of the queue the job was fetched from. |
||
20 | 2 | */ |
|
21 | public function __construct($payload, $exception, $worker, $queue) |
||
22 | 2 | { |
|
23 | 2 | $data = new stdClass(); |
|
24 | 2 | $data->failed_at = date('c'); |
|
25 | 2 | $data->payload = $payload; |
|
26 | 2 | $data->exception = get_class($exception); |
|
27 | 2 | $data->error = $exception->getMessage(); |
|
28 | 2 | $data->backtrace = explode("\n", $exception->getTraceAsString()); |
|
29 | 2 | $data->worker = (string)$worker; |
|
30 | 2 | $data->queue = $queue; |
|
31 | 2 | $data = json_encode($data); |
|
32 | 2 | Resque::redis()->rpush('failed', $data); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
33 | } |
||
34 | } |
||
35 |