| 1 | <?php |
||
| 7 | class Consumer |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var QueueReader |
||
| 11 | */ |
||
| 12 | protected $queueReader; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Consumer constructor. |
||
| 16 | * @param QueueReader $queueReader |
||
| 17 | */ |
||
| 18 | public function __construct(QueueReader $queueReader) |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Consumes tasks indefinitely in a blocking manner |
||
| 25 | * @param callable $callback Callable that'll be invoked when a message is received |
||
| 26 | * @param int $timeout (optional) If specified, the process will block a max of $timeout seconds. Indefinitely if 0 |
||
| 27 | */ |
||
| 28 | public function consume(callable $callback, $timeout=0) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Purges all messages from the queue |
||
| 41 | */ |
||
| 42 | public function purge() |
||
| 46 | } |