1 | <?php |
||
9 | class Worker |
||
10 | { |
||
11 | /** |
||
12 | * @var DriverInterface |
||
13 | */ |
||
14 | private $driver; |
||
15 | |||
16 | /** |
||
17 | * @var Queue |
||
18 | */ |
||
19 | private $queue; |
||
20 | |||
21 | /** |
||
22 | * @var Event |
||
23 | */ |
||
24 | private $event; |
||
25 | |||
26 | /** |
||
27 | * @var CommandBus |
||
28 | */ |
||
29 | private $command_bus; |
||
30 | |||
31 | /** |
||
32 | * Will shutdown the worker on the next tick |
||
33 | * |
||
34 | * @var bool |
||
35 | */ |
||
36 | private $shutdown = false; |
||
37 | |||
38 | /** |
||
39 | * Will shutdown the worker when the queue is drained |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | private $drain = false; |
||
44 | |||
45 | 7 | public function __construct( |
|
56 | |||
57 | /** |
||
58 | * Consumes messages off of the queue |
||
59 | * |
||
60 | * @codeCoverageIgnore |
||
61 | * |
||
62 | * @param string $queue |
||
63 | */ |
||
64 | public function consume($queue) |
||
72 | |||
73 | /** |
||
74 | * Handles fetching messages from the queue |
||
75 | * |
||
76 | * @param string $queue |
||
77 | * |
||
78 | * @return bool |
||
79 | */ |
||
80 | 5 | protected function tick($queue) |
|
107 | |||
108 | /** |
||
109 | * Handles binding POSIX signals appropriately |
||
110 | * |
||
111 | * @codeCoverageIgnore |
||
112 | */ |
||
113 | private function bindSignals() |
||
127 | |||
128 | /** |
||
129 | * Set the worker to shutdown on the next tick |
||
130 | */ |
||
131 | 1 | private function shutdown() |
|
135 | |||
136 | /** |
||
137 | * Set the worker to shutdown when the queue is drained |
||
138 | */ |
||
139 | 1 | private function drain() |
|
143 | } |
||
144 |