1 | <?php |
||
10 | class Worker |
||
11 | { |
||
12 | /** |
||
13 | * @var DriverInterface |
||
14 | */ |
||
15 | private $driver; |
||
16 | |||
17 | /** |
||
18 | * @var Event |
||
19 | */ |
||
20 | private $event; |
||
21 | |||
22 | /** |
||
23 | * @var LoggerInterface |
||
24 | */ |
||
25 | private $logger; |
||
26 | |||
27 | /** |
||
28 | * @var CommandFactoryInterface |
||
29 | */ |
||
30 | private $commands; |
||
31 | |||
32 | /** |
||
33 | * @param DriverInterface $driver |
||
34 | * @param Event $event |
||
35 | * @param LoggerInterface $logger |
||
36 | * @param CommandFactoryInterface $commands |
||
37 | */ |
||
38 | public function __construct( |
||
49 | |||
50 | /** |
||
51 | * Consumes messages off of the queue |
||
52 | * |
||
53 | * @param string $queue |
||
54 | */ |
||
55 | public function consume($queue) |
||
59 | |||
60 | /** |
||
61 | * Handles fetching messages from the queue |
||
62 | * |
||
63 | * @param string $queue |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | protected function tick($queue) |
||
87 | |||
88 | /** |
||
89 | * Invoke the options command |
||
90 | * |
||
91 | * @param AbstractOptions $options |
||
92 | * |
||
93 | * @return null|bool |
||
94 | */ |
||
95 | private function invoke(AbstractOptions $options) |
||
108 | |||
109 | /** |
||
110 | * Handles actions related to a job starting |
||
111 | * |
||
112 | * @param AbstractOptions $options |
||
113 | */ |
||
114 | private function jobStart(AbstractOptions $options) |
||
119 | |||
120 | /** |
||
121 | * Handles actions related to a job finishing |
||
122 | * |
||
123 | * @param AbstractOptions $options |
||
124 | */ |
||
125 | private function jobFinish(AbstractOptions $options) |
||
130 | |||
131 | /** |
||
132 | * Handles actions related to a job shutting down the consumer |
||
133 | * |
||
134 | * @param AbstractOptions $options |
||
135 | */ |
||
136 | private function jobShutdown(AbstractOptions $options) |
||
140 | |||
141 | /** |
||
142 | * Handles actions related to job exceptions |
||
143 | * |
||
144 | * @param AbstractOptions $options |
||
145 | * @param Exception $exception |
||
146 | */ |
||
147 | private function jobException(AbstractOptions $options, Exception $exception) |
||
152 | } |
||
153 |