1 | <?php |
||
13 | class Consumer |
||
14 | { |
||
15 | protected $router; |
||
16 | protected $dispatcher; |
||
17 | protected $shutdown = false; |
||
18 | protected $pause = false; |
||
19 | protected $configured = false; |
||
20 | protected $options = [ |
||
21 | 'max-runtime' => PHP_INT_MAX, |
||
22 | 'max-messages' => null, |
||
23 | 'stop-when-empty' => false, |
||
24 | 'stop-on-error' => false, |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * @param Router $router |
||
29 | * @param EventDispatcherInterface $dispatcher |
||
30 | */ |
||
31 | public function __construct(Router $router, EventDispatcherInterface $dispatcher) |
||
36 | |||
37 | /** |
||
38 | * Starts an infinite loop calling Consumer::tick(); |
||
39 | * |
||
40 | * @param Queue $queue |
||
41 | * @param array $options |
||
42 | */ |
||
43 | public function consume(Queue $queue, array $options = []) |
||
53 | |||
54 | /** |
||
55 | * Returns true do indicate it should be run again or false to indicate |
||
56 | * it should not be run again. |
||
57 | * |
||
58 | * @param Queue $queue |
||
59 | * @param array $options |
||
60 | * |
||
61 | * @return boolean |
||
62 | */ |
||
63 | public function tick(Queue $queue, array $options = []) |
||
94 | |||
95 | /** |
||
96 | * Mark Consumer as shutdown |
||
97 | */ |
||
98 | public function shutdown() |
||
102 | |||
103 | /** |
||
104 | * Pause consuming |
||
105 | */ |
||
106 | public function pause() |
||
110 | |||
111 | /** |
||
112 | * Resume consuming |
||
113 | */ |
||
114 | public function resume() |
||
118 | |||
119 | /** |
||
120 | * Until there is a real extension point to doing invoked stuff, this can be used |
||
121 | * by wrapping the invoke method. |
||
122 | * |
||
123 | * @param Envelope $envelope |
||
124 | * @param Queue $queue |
||
125 | */ |
||
126 | public function invoke(Envelope $envelope, Queue $queue) |
||
150 | |||
151 | /** |
||
152 | * @param array $options |
||
153 | */ |
||
154 | protected function configure(array $options) |
||
164 | |||
165 | /** |
||
166 | * Setup signal handlers for unix signals. |
||
167 | */ |
||
168 | protected function bind() |
||
176 | } |
||
177 |