1 | <?php |
||
4 | abstract class BaseJob implements JobInterface |
||
5 | { |
||
6 | /** |
||
7 | * Job ID |
||
8 | * |
||
9 | * @var string |
||
10 | */ |
||
11 | protected $id; |
||
12 | |||
13 | /** |
||
14 | * Job body |
||
15 | * |
||
16 | * This is the job data. Whether just an integer, an array, that depends |
||
17 | * on the use case. |
||
18 | * |
||
19 | * @var mixed |
||
20 | */ |
||
21 | protected $body; |
||
22 | |||
23 | /** |
||
24 | * The name of the queue the job belongs to |
||
25 | * |
||
26 | * This is optional and can be null eg. when adding a new job. |
||
27 | * It can however be used to identify what queue the job came from, |
||
28 | * eg. in case of a consumer reading from multiple queues. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $queue; |
||
33 | |||
34 | /** |
||
35 | * The number of NACKs this job has received |
||
36 | * |
||
37 | * NACK is a command which tells Disque that the job wasn't processed |
||
38 | * successfully and it should return to the queue immediately. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $nacks = 0; |
||
43 | |||
44 | /** |
||
45 | * The number of times this job has been re-delivered for reasons other |
||
46 | * than a NACK |
||
47 | * |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $additionalDeliveries = 0; |
||
51 | |||
52 | /** |
||
53 | * An optional shortcut for instantiating the job with one call |
||
54 | * |
||
55 | * To make it more flexible, all arguments in the constructor are optional |
||
56 | * and the job can be populated by calling the setters. |
||
57 | * |
||
58 | * @param mixed $body Body The job body |
||
59 | * @param string $id The job ID |
||
60 | * @param string $queue Name of the queue the job belongs to |
||
61 | * @param int $nacks The number of NACKs |
||
62 | * @param int $additionalDeliveries The number of additional deliveries |
||
63 | */ |
||
64 | public function __construct( |
||
77 | |||
78 | /** |
||
79 | * @inheritdoc |
||
80 | */ |
||
81 | public function getBody() |
||
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | public function setBody($body) |
||
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | public function getId() |
||
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | public function setId($id) |
||
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | public function getQueue() |
||
117 | |||
118 | /** |
||
119 | * @inheritdoc |
||
120 | */ |
||
121 | public function setQueue($queue) |
||
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | public function getNacks() |
||
133 | |||
134 | /** |
||
135 | * @inheritdoc |
||
136 | */ |
||
137 | public function setNacks($nacks) |
||
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | public function getAdditionalDeliveries() |
||
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | public function setAdditionalDeliveries($additionalDeliveries) |
||
157 | } |
||
158 |